CREATE DATABASE `db1`;
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'nvlcoj17jajtwhs4';
GRANT ALL PRIVILEGES ON db1.* TO `user1`@`localhost`;
REVOKE ALL PRIVILEGES ON db1.* FROM `user1`@`localhost`;
DROP DATABASE IF EXISTS `db1`;
DROP USER 'user1'@'localhost';
I often forget how to create a database, how to create user or how to grant user privileges to the database.
Creating a database is simple command 'CREATE DATABASE' followed by database name.
Creating a database user is another simple command 'CREATE USER' and
Granting access to the database is 'GRANT ALL PRIVILEGES'. While these details are easily found in MySQL manual, I wanted to make it easier to find and generate.
For more details check: