▲mysql Users
MySQL database has only one root user by default
MySQL database saves user information in the MySQL database's UESR data sheet
▲mysql User Management
#创建一个新的用户
CREATE user username identified by ' password ';
Note: A new user cannot log in after creation because no permissions are set
#重命名一个用户
RENAME user name to new user name;
#删除一个用户
DROP user username;
#修改当前用户的密码
SET PASSWORD = PASSWORD (' password ');
Note: The password can be encrypted using password (' password ')
#修改指定用户密码
SET PASSWORD for User name = PASSWORD (' password ');
▲mysql Permission System
The MySQL privilege system can check if the user is able to connect, and can check if the user has permission to perform the action
The level of permission that MySQL grants can be divided into: global level, database level, surface level, column level, sub-program level
MySQL grants permissions through grant, revoking permissions through revoke
▲mysql Authorization Command
#授予一个用户权限
GRANT all privileges the on level to user name @ host identified by ' password ';
For example: Grant all privileges the stock.* to ' wddoer ' @ '% ' identified by ' password '; grant the user wddoer all permissions on the stock database
#撤销一个用户权限
REVOKE all privileges from user name;
#MySQL连接认证
When connecting to the MySQL service, MySQL verifies that the connection is allowed by the three points of username, password and host information.
Host:% for all hosts, localhost for native, 192.168.0.1 or www.wddoer.com for exact IP address or hostname, * for wildcard, 192.168.0.1/192.168.0.100 to designate a network segment
Note: The root user can only connect locally from the host by default
Discussion on MySQL user and rights management