Grant a privilege to a MySQL user on a database

October 27, 2013 | Last tested: May 2015 | 763 views | Comments

To be able for a MySQL user to add, edit, delete, and select records from a database, a permission should be first granted to be able to access a MySQL database to perform the said operations.

For example.

Grant a permission to a user named "coder" on the database named "Tutorials", for which the user is under the host name "localhost".

GRANT ALL PRIVILEGES ON Tutorials.* TO 'coder'@'localhost';

Take note that FLUSH PRIVILEGES is important because it reloads the privileges from the grant tables in the MySQL database, without it, the privileges granted won't take an effect.