Howtos / Articles

Grant a MySQL user access to a database

If you have a existing MySQL user account that you want to grant permissions to for a specific database, this howto will outline the steps required.

Run the MySQL client:

$ mysql -u root -p

You will be asked for a password. If you don’t have a password set, simply press enter when prompted.

Grant access to the specific database:

GRANT ALL ON databasename.* TO 'username'@'localhost';

Change ‘databasename’ and ‘username’ to suit your requirements.

Flush the privileges to make sure the newly added user and permissions are ready to use:


Exit the MySQL client:


If you need to create a new user, see the following howto:
Create a new user in MySQL

Share this howto article!
  • Facebook
  • Twitter
  • Reddit
  • email

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>