DCL--数据控制语言

1.授权命令 grant

#1.授权
grant all on *.* to root@'172.16.1.%' identified by '123';
#应该授权低一点的权限
grant select,update,insert on database.* to dev@'172.16.1.%' identified by 'Lhd@123456'

#2.查看用户权限
mysql> show grants for root@'localhost';

#3.特殊权限授权
max_queries_per_hour:一个用户每小时可发出的查询数量
max_updates_per_hour:一个用户每小时可发出的更新数量

max_connections_per_hour:一个用户每小时可连接到服务器的次数
mysql> grant all on *.* to lhd@'localhost' identified by '123' with max_connections_per_hour 1;

max_user_connections:允许同时连接数量
mysql> grant all on *.* to test@'localhost' identified by '123' with max_user_connections 2;

2.回收权限 revoke

#1.回收权限
mysql> revoke drop on *.* from test@'localhost';

#2.查看权限
mysql> show grants for test@'localhost';

#3.所有权限
SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE

3.授权一个超级管理员

mysql> grant all on *.* to superuser@'localhost' identified by 'Lhd@123456' with grant option;
原文地址:https://www.cnblogs.com/chenlifan/p/13907183.html