Note to Self Mysql Create User

MySQL: Create user

Quick note, create user in MySQL CLI:

Login into mysql:

mysql -u root -p
#remote
mysql -u root -h <server_hostname> -p
CREATE DATABASE <database>;
CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON <database>.* TO '<username>'@'localhost';
FLUSH PRIVILEGES;
#show users
SELECT User FROM mysql.user;
#show tables
SHOW databases;

If you need to delete a user:

DROP USER '<username>'@'localhost';

To revoke permissions:

REVOKE <permission> ON <database>.<table> FROM '<username>'@'localhost';

Test new user:

#exit mysql console
\q

Login again with the new user:

mysql -u <username> -p

User permissions: