Mysql User Administration

mysql> CREATE USER 'rahan'@'localhost' IDENTIFIED BY 'abc123';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'rahan'@'localhost' WITH GRANT OPTION;

mysql> CREATE USER 'dummy'@'localhost';

Checking The Privileges

mysql>SHOW GRANTS for 'rahan'@'localhost';

Alter native to creating user account .

You could manualy enter the user information in the mysql user table.

mysql> INSERT INTO mysql.user VALUES('localhost','rahan',PASSWORD('abc123'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');

mysql> FLUSH PRIVILEGES;

Granting Specific Privileges to user.

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO 'rahan'@'localhost';

For the privileges to immediately take effect, use the flush privileges command to flush the privilege config from memory

mysql>flush privileges;

To check privileges (grants) of current user

mysql>show grants on current_user();

Renaming user account.

mysql>RENAME USER 'rahan'@'localhost' TO 'r1'@'rac1';

Revoking privileges (grants)

mysql>REVOKE INSERT ON *.* FROM 'rahan'@'localhost';

Re-setting password.

mysql>SET PASSWORD FOR 'rahan'@'localhost' = PASSWORD('xyz123');