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
CREATE
Create new tables or databasesDROP
Delete tables or databasesDELETE
Delete rows from tablesINSERT
Insert rows into tablesSELECT
Select command to read through databasesUPDATE
Update table rowsGRANT OPTION
Manage other users' privilegesALL PRIVILEGES