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
CREATECreate new tables or databasesDROPDelete tables or databasesDELETEDelete rows from tablesINSERTInsert rows into tablesSELECTSelect command to read through databasesUPDATEUpdate table rowsGRANT OPTIONManage other users' privilegesALL PRIVILEGES