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;
    
  • 相关阅读:
    golang模板语法简明教程(后面有福利哦)
    C#实现jQuery的方法连缀
    静态构造函数
    MVC4 中使用 Area 和 注意的地方
    APS.NET MVC4生成解析二维码简单Demo
    net mvc 利用NPOI导入导出excel
    Ambari DataNode Start Failure
    Java的三种代理模式
    清理ambari安装的hadoop集群
    【小型系统】简单的刷票系统(突破IP限制进行投票)
  • 原文地址:https://www.cnblogs.com/tcy1/p/13305944.html
Copyright © 2011-2022 走看看