zoukankan      html  css  js  c++  java
  • sql语句之DCL

    DCL: 数据控制语言 (grant、revoke)

    1.grant授权

    #0.授权语句
    grant all on *.* to root@'172.16.1.%' identified by '123';
    
    #1.查看用户权限
    mysql> show grants for root@'localhost';
    | Grants for root@localhost |
    | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*23AE809DDACAF96AF0FD78ED04B6A265E05AA257' WITH GRANT OPTION |
    | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION   |
    
    
    #2.全库全表授权
    mysql> grant all on *.* to root@'172.16.1.%' identified by '123';
    Query OK, 0 rows affected (0.00 sec)
    
    #3.单库授权
    mysql> grant all on mysql.* to root@'172.16.1.%' identified by '123';
    Query OK, 0 rows affected (0.00 sec)
    
    #4.单表授权
    mysql> grant all on mysql.user to root@'172.16.1.%' identified by '123';
    Query OK, 0 rows affected (0.00 sec)
    
    #5.单列授权(脱敏)
    mysql> grant select(user,host) on mysql.user to root@'172.16.1.%' identified by '123';
    Query OK, 0 rows affected (0.00 sec)
    
    #6.扩展参数
    max_queries_per_hour:一个用户每小时可发出的查询数量
    mysql> grant all on *.* to root@'172.16.1.%' identified by '123' with max_queries_per_hour 2;
    Query OK, 0 rows affected (0.00 sec)
    
    max_updates_per_hour:一个用户每小时可发出的更新数量
    mysql> grant all on *.* to root@'172.16.1.%' identified by '123' with max_updates_per_hour 2;
    Query OK, 0 rows affected (0.00 sec)
    
    max_connetions_per_hour:一个用户每小时可连接到服务器的次数
    mysql> grant all on *.* to lhd@'172.16.1.%' identified by '123' with max_connections_per_hour 2;
    Query OK, 0 rows affected (0.00 sec)
    
    max_user_connetions:允许同时连接数量
    mysql> grant all on *.* to lhd@'172.16.1.%' identified by '123' with max_user_connections 1;
    Query OK, 0 rows affected (0.00 sec)
    

    2.revoke回收权限

    mysql> revoke drop on *.* from lhd@'172.16.1.%';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show grants for lhd@'172.16.1.%';
    | Grants for lhd@172.16.1.%                                                                           
    | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, 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 ON *.* TO 'lhd'@'172.16.1.%' IDENTIFIED BY PASSWORD '*23AE809DDACAF96AF0FD78ED04B6A265E05AA257' WITH MAX_CONNECTIONS_PER_HOUR 2 MAX_USER_CONNECTIONS 1
    
    #所有权限
    SELECT, INSERT, UPDATE, DELETE, CREATE, 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, DROP, GRANT
    

    3.授权超级管理员

    grant all on *.* to root@'172.16.1.%' identified by '123' with grant option;
    
  • 相关阅读:
    SQL中的count()函数内加条件
    SpringBoot+Vue实现第三方微博登录(二)
    SpringBoot+Vue实现第三方百度登录(一)
    Javascript unescape 的 Sql Server 实现
    DataGridView 行内编辑探索
    JQuery Offset实验与应用
    垃圾代码是这样练成的......
    关于前天发现的可能是VS2005服务器资源管理器的bug ...
    调试
    可怕的误导,来自(iHeavy Inc.公司的高级顾问Sean Hull的谬论... )
  • 原文地址:https://www.cnblogs.com/tcy1/p/13305944.html
Copyright © 2011-2022 走看看