MySQL create databases and user from a to z

How can I create a database and an user to work together in MySQL. Well, it’s quit easy, theres the few MySQL lines you need to use to solve your problem.

Create the database

[cce_mysql]
CREATE database my_db;
[/cce_mysql]

Create an user

[cce_mysql]
CREATE USER ‘my_user’@’localhost’ IDENTIFIED BY ‘my_pass’;
[/cce_mysql]

Verify user

[cce_mysql]
SELECT * FROM mysql.user WHERE User = ‘my_user’G
[/cce_mysql]

Grant privileges to user

[cce_mysql]
GRANT ALL ON my_db.* TO ‘my_user’@’localhost’;
[/cce_mysql]

Verify user GRANTS

[cce_mysql]
SHOW GRANTS FOR my_user@localhost;
[/cce_mysql]

Leave a Reply