Last Updated: February 25, 2016
·
470
· angezanetti

MySQL : Create a user with his own database

I do it all the time when i start a new project, create a user with the database based on the same name, where the new user got ALL privileges on the base.

Pretty usefull, but i forget the exact syntax every time, here is the code :

CREATE DATABASE db_name;
GRANT ALL PRIVILEGES ON db_name.* TO "username"@"localhost"      IDENTIFIED BY 'password';
FLUSH PRIVILEGES;