Wednesday, June 1, 2011

How to create a new user in mysql

Sponsored Links
Creating a new super user

The command is :
mysql> GRANT ALL PRIVILEGES ON *.* TO 'randeep'@'%' IDENTIFIED BY 'randeep' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;
+---------+----------------+------------------+
| user | host | password |
+---------+----------------+------------------+
| root | localhost | 27c30f0241a5b69f |
| root | mysql.lap.work | 27c30f0241a5b69f |
| root | 127.0.0.1 | 27c30f0241a5b69f |
| randeep | % | 0d9b9da57a2d7649 | >> new user (% means all hosts)
+---------+----------------+------------------+
4 rows in set (0.00 sec)
mysql>


Creating a user without grant option :

mysql> grant all privileges on *.* to 'abc'@'localhost' identified by 'abc123';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from user;
+---------+----------------+------------------+
| user | host | password |
+---------+----------------+------------------+
| root | localhost | 27c30f0241a5b69f |
| root | mysql.lap.work | 27c30f0241a5b69f |
| root | 127.0.0.1 | 27c30f0241a5b69f |
| abc | localhost | 4b5698aa4603595b | >> newly added user.
| randeep | % | 0d9b9da57a2d7649 |
+---------+----------------+------------------+
5 rows in set (0.01 sec)
mysql>
Sponsored Links

No comments:

Post a Comment

Be nice. That's all.