First, create a user : Log in to the database as root user creation
Command:
CREATE USER ' username '@'host'by'password';
For example:
CREATE USER ' Test_admin '@'localhost'by'[email protected]_s' ; CREATE USER ' test_admin2 '@'%'by';
Note
username--the user name that will be created;
host--specifies on which host the user can log on, "localhost" means that the user may log on locally only, cannot telnet on another machine, if you want to telnet, change "localhost" to "%", which means you can log on on any computer Or you can designate a machine to log in remotely;
password--The user's login password, the password can be empty, and if it is empty, the user can log on to the server without a password.
Ii. Authorization : Log in to the database as the root user for authorization
Command:
GRANT Privileges on to ' username '@'host'
Note
privileges--the user's operating rights, such as SELECT. Use all if all permissions are granted.
databasename--the database name. tablename--the table name. If you want to grant the user the appropriate operation permissions for all databases and tables, the * representation is available, for example, *. *
For example:
GRANT SELECT on test_db. * to ' test_admin2 '@'%'privilegesprivileges;
Third, revoke user rights
Command:
REVOKE on from ' username '@'host';
For example:
REVOKE SELECT on test_db. * from ' Test_min '@'%';
Iv. Deletion of accounts and privileges :
Command:
Drop User ' username '@'host';
V. viewing the user's authorization
Command:
for ' username '@'host'
For example:
Mysql>SHOW GRANTS for 'Test_admin'@'%' ;+----------------------------------------------------------------+|Grants for[Email protected]% |+----------------------------------------------------------------+| GRANTUSAGE on *.* to 'Test_admin'@'%' || GRANT All Privileges on' test_manage_db '.* to 'Test_admin'@'%' |+----------------------------------------------------------------+2Rowsinch Set(0.00sec) MySQL>
Centos7--mysql 5.7 Adding users, deleting users, and authorizing