Saturday, September 21, 2013

MySQL - Create a new user



Connect to MySQL server - 
mysql -u root -p -h hostname

Execute the below command from mysql client
CREATE USER 'user_name'@'%' IDENTIFIED BY 'pwd';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX  ON db_name.* TO 'user_name'@'%';

We can add more privileges  like DROP if the user/application needs to drop any tables.