mysql adds ordinary users and authorizes them

1. Create a user

create user '[用户名称]'@'%' identified by '[用户密码]';

The password is more than 8 characters, including: uppercase letters, lowercase letters, numbers, special characters
%: match all hosts, this place can also be set to'localhost', which means that only local access is possible, for example, the root account defaults to'localhost'

2. User authorization database

1) Specify the database read and write permissions

grant select,insert,update,delete,create on [数据库名称].* to [用户名称];

2) All the library read and write permissions
[database name] replaced by * represents the entire database

grant select,insert,update,delete,create on *.* to [用户名称];

3) Specify all operation permissions of the library

grant all privileges on  [数据库名称].* to [用户名称];

4) All operating permissions for all libraries

grant all privileges on *.* to [用户名称];

3. Enable modification immediately

flush  privileges ;

4. Cancel all permissions of all databases (tables) of the user

revoke all on *.* from [用户名称];

5. Delete users

delete from mysql.user where user= [用户名称];

6, delete the database

drop database [schema名称|数据库名称];

Example:

create user 'test'@'%' identified by 'test@abc'; -- 创建用户
grant select,insert,update,delete,create on *.* to test; --用户授权数据库
flush privileges;--立即启用修改

Guess you like

Origin blog.csdn.net/weixin_41003771/article/details/114536758