Wednesday, September 7, 2011

Create user in Mysql DB and grant all privileges.



Ref: http://www.databasef1.com/tutorial/mysql-create-user.html

        http://lists.mysql.com/mysql/206641

[root@b6253 ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: YES)
[root@b6253 ~]# /etc/init.d/mysqld stop
Stopping MySQL:                                            [  OK  ]
[root@b6253 ~]# ps -ef | grep mysql
[root@b6253 ~]#
[root@b6253 ~]# mysqld_safe --skip-grant-tables &
[1] 14884
[root@b6253 ~]# Starting mysqld daemon with databases from /var/lib/mysql

[root@b6253 ~]#
[root@b6253 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE user SET Password=xxxxxxx('xxxxxx') where USER='root';
    -> FLUSH PRIVILEGES;
ERROR 1046 (3D000): No database selected

ERROR 1290 (HY000): The MySQL server is running with the
--skip-grant-tables option so it cannot execute this statement

[root@b6253 ~]# /etc/init.d/mysqld restart

mysql> CREATE USER 'db-abc'@'localhost' IDENTIFIED BY 'bsa2206';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON abc.* TO 'db-abc'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> select * from mysql.user;

No comments:

Post a Comment