1. 程式人生 > 實用技巧 >DCL--資料控制語言

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;