Friday, 9 October 2015

Create a new user in MYSQL and provide PRIVILEGES to new user




1. Install mysql in ubuntu using below command:

sudo apt-get install mysql-server mysql-client

2. Connect to mysql using below command:
mysql -u root -p

provide mysql password given as part of installation step1


3. Create a new user in mysql with password

CREATE USER 'username'@'hostname' IDENTIFIED BY 'password';


4. Revoke all privileges to new user

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'hostname';


5. Grant required privileges to new user to specific database

GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES,EXECUTE ON databasename.* TO 'username'@'hostname';
6. Grant required privileges to new user to all databases

GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES,EXECUTE ON *.* TO 'username'@'hostname';


7. Commit the changes
FLUSH PRIVILEGES;


8. Exit from mysql

quit;


9. Test the above steps are working or not using below command:

mysql -u username -p -h hostname

provide the 'password'
10. After verification , exit from mysql

quit;




Related Posts Plugin for WordPress, Blogger...