User section of commands commonly used in mysql
New user:
Create user user name;-- create an empty password user.
Create user username IDENTIFIED BY 'password';-- create a password when you create a new user.
Grant select [, insert...] On mysql.user to username identified by 'password';-while creating a new user, grant the user permission to user table in select mysql database.
Update password:
1. Set password=password ('password');-- modify the current user password.
2. Set password for user name = password ('password');-- modify the specified user password.
3. Update mysql.user set password=password ('password') where user=' username'- modify it directly with update
Flush privilegs;-updates memory to make it work
View user permissions:
Use mysql
Select * from user where User='test'\ G;-- format the permissions of the test user.
Delete a user:
Delete from user where user='';-delete the column with empty user name in the user table and add from. Prevent task users from being able to log in freely
Flush privileges;-flush the memory to make the changes take effect
Authorize the user:
Grant all on mysql.user to test@'%';-gives all users named test all permissions for the user table of the mysql database.
Grant all on stu.* to test2@'%';-Grant all test2 users access to the stu database
Query user permissions:
Select * from mysql.user where user=' any user name';-- query the user's permissions at the database level
Show grants;-query current user permissions
Show grants for user name;-- query the permissions of the specified user
Change the permissions:
Revoke all privileges on mysql.user from test;-reclaims all permissions of the test user on the mysql.user data table.
Revoke select on mysql.user from test2;-reclaims test2's select permissions on mysql.user data tables.