1. New User
Create a test user with a password of 1234.
Mysql-u root-p
CREATE USER "Test" @ "localhost" identified by "1234"; #本地登录
CREATE USER "Test" @ "%" identified by "1234"; #远程登录
Quit
Mysql-utest-p #测试是否创建成功
2, for the user authorization
A. Authorization format: Grant permissions on the database. * To username @ Login host identified by "password";
B. Log in to MySQL and log in as root here:
Mysql-u root-p
C. Create a database for the user (TestDB):
Create Database TestDB;
Create DATABASE TestDB default charset UTF8 collate utf8_general_ci;
D. Authorize the test user to have all permissions for the TestDB database:
Grant all privileges the testdb.* to "test" @ "localhost" identified by "1234";
Flush privileges; #刷新系统权限表
E. Specify partial permissions to the user:
Grant Select,update on testdb.* to "test" @ "localhost" identified by "1234";
Flush privileges; #刷新系统权限表
F. Authorize the test user to have some permissions for all databases:
Grant Select,delete,update,create,drop [ email protected] "%" identified by "1234"; # "%" means authorization for all non-local hosts, excluding localhost
3. Delete users
Mysql-u root-p
Delete from Mysql.user Where user= "test" and host= "localhost";
Flush privileges;
Drop database TestDB;
Delete accounts and permissions:
Drop user username @ '% ';
Drop user username @ localhost;
4. Modify the specified user password
Mysql-u root-p
Update Mysql.user Set Authentication_string=password ("New password") where user= "test" and host= "localhost";
Flush privileges;
MYSQL 5.7 Add user, new database, user authorization, delete user, change password