Networking HowTos
Networking HowTos

Grant a MySQL user access to a database

January 1, 2013 Database, MySQL

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:

FLUSH PRIVILEGES;

Exit the MySQL client:

exit

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

You Might Also Like