New User:
Create user username; --Create an empty password user.
Create user username identified by ' password '; -Create a password when creating a new user.
Grant Select[,insert ...] on Mysql.user to username identified by ' password '; --Create a new user and grant the user the right to select the MySQL database user table.
Update Password:
1. Set Password=password (' Password '); --modifies the current user password.
2. Set password for user name =password (' password '); --modifies the specified user password.
3. Update Mysql.user set Password=password (' Password ') where user= ' username '--Modified directly with update
Flush Privilegs; --Update the memory to make it effective
To view User rights:
Use MySQL
SELECT * from user where user= ' test ' \g; --Format to view the permissions of the test user.
To delete a user:
Delete from user where user= '; --Remove the User Name column from the Users table, and add the from. Prevent task users from being able to log in freely
Flush privileges; --Refresh the memory for the changes to take effect
To authorize the user:
Grant all on mysql.user to [email protected] '% '; --Give all permissions to the user table in the MySQL database for all users named Test.
Grant all on stu.* to [email protected] '% '; --Give all TEST2 users permission to the STU database
Query user permissions:
SELECT * from Mysql.user where user= ' random username '; --Querying user permissions at the database level
Show grants; --Query Current user permissions
Show grants for user name; --Query the permissions of the specified user
Change permissions:
Revoke all privileges in mysql.user from test; --Reclaims all the permissions of the test user on the Mysql.user data sheet.
Revoke select on Mysql.user from Test2; --Reclaim Test2 's SELECT permission on the Mysql.user data table.
MySQL common commands user's chapter