Creating New User in MySQL

When you create a new database in MySQL, it is a good idea to associate a new user(s) with the database. Here are the steps that you will need to follow.

  • Create new database
  • Create new user
     create user <username> identified by '<password>';

This will create a new user with the specified password.

  • Grant privileges: Next you will have to grant privileges to the newly created user (above) so that he can do the required operations on the database. This is done by
           grant all privileges on <db name>.<table name> to '<username>';

           flush privileges;

If you want to give privileges to all the tables, replace table name with *. Likewise, if you want to give privileges to all databases, replace the dbname with *.

Login with the new user and check that the required permissions are available.



Suresh Kumar Neti has written 7 articles

Has over 26 years of experience in various roles in software industry. As the Founder and CEO of Neti Software Services, loves finding solutions to problems faced by the customers.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>