1. Add user
1. Create only allow specified ip connection
create user '新用户名'@'localhost' identified by '密码';
2. Create to allow all ip connections (indicated by wildcard %)
create user '新用户名'@'%' identified by '密码';
2. Authorize new users
1. The basic format is as follows
grant all privileges on 数据库名.表名 to '新用户名'@'指定ip' identified by '新用户密码' ;
For example:
(1) Allow access to all tables under all databases
grant all privileges on *.* to '新用户名'@'指定ip' identified by '新用户密码' ;
(2) The specified table under the specified database
grant all privileges on test.test to '新用户名'@'指定ip' identified by '新用户密码' ;
3. Set user operation permissions
1. Set users to have all permissions, that is, administrators
grant all on *.* to '用户名'@'%';
2. Possess query authority
grant select on *.* to '新用户名'@'指定ip' identified by '新用户密码' WITH GRANT OPTION;
3. Instructions for other operation permissions, select query insert insert delete delete update modify
(1) set the user to have query insert permission
grant select,insert on *.* to '新用户名'@'指定ip' identified by '新用户密码' WITH GRANT OPTION;
(2) Cancel the query permission of user query
REVOKE select ON what FROM '新用户名';
4. Delete user
DROP USER username@localhost;
5. Refresh permissions after modification
FLUSH PRIVILEGES;