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.

 

 

Leave a Reply

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