zoukankan      html  css  js  c++  java
  • mysql授权用户,撤销用户,撤销权限基本操作

    进入mysql库

    use mysql;
    mysql> select host,user from user;
    +-----------+---------------+
    | host      | user          |
    +-----------+---------------+
    | %         | root          |
    | localhost | mysql.session |
    | localhost | mysql.sys     |
    | localhost | root          |
    +-----------+---------------+
    4 rows in set (0.00 sec)
    
    select host,user from user where user='root';

    将相应用户数据表中的host字段改成'%';

    update user set host='%' where user='root';
    update user set host='localhost' where user='root' and host='192.168.%.%';
    //ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理会
    flush privileges

    授权用户

    grant all privileges on *.* to 'root'@'172.18.%.%' identified by '123456' with grant option;
    grant all privileges on *.* to 'root'@'192.168.1.%' identified by '123456' with grant option;

    撤销权限

    revoke all privileges on *.* from root@'%';
    revoke all privileges on db01.* from root@'%';

    删除用户

    drop user 'test'@'localhost';

    查看用户的授权

    mysql> SHOW GRANTS FOR 'user01'@'%';
    +--------------------------------------------------------+
    | Grants for user01@%                                 |
    +--------------------------------------------------------+
    | GRANT USAGE ON *.* TO 'root'@'%'                  |
    | GRANT ALL PRIVILEGES ON `db01`.* TO 'user01'@'%' |
    +--------------------------------------------------------+
    2 rows in set (0.00 sec)
    
    //USAGE:create user时的默认的空权限,只能连库,所以user01现在的权限是在mysql01数据库上有所有的权限。
  • 相关阅读:
    牛牛与LCM(最小公约数)
    小明的挖矿之旅_牛客网(思维题)
    2019/4/20周赛 F题 CodeForces
    哥德巴赫猜想_2019/7/11_牛客网
    智障操作-wireless AC 9462
    codeforces762A
    2019中山大学程序设计竞赛(重现赛)斐波那契/
    Java自学笔记(10):【面向对象 】 类和对象、构造方法、this关键字
    Java自学笔记(9):方法
    Java自学笔记(8):多维数组
  • 原文地址:https://www.cnblogs.com/linyouyi/p/10648880.html
Copyright © 2011-2022 走看看