• Linux11.3 MySQL用户管理


      创建用户

    mysql> grant all on *.* to 'user1'@‘127.0.0.1’ identified by '123qwe';
    Query OK, 0 rows affected (0.00 sec)
    
    第一个*,表示库名,所有的库
    第二个*,表示表,所有的表
    @后面为该用户所登录的IP,%为所有IP
    identified by 后面为密码
    

      针对具体的权限授权

    grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.133.1' identified by '123qwe';
    

      如果授权一个用户的IP需要修改,可以在不知道其密码情况下修改

    mysql> grant SELECT,INSERT on db1.* to 'user2'@'192.168.212.130' identified by '123qwe';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show grants for user2@'192.168.212.130';
    +--------------------------------------------------------------------------------------------------------------------+
    | Grants for user2@192.168.212.130                                                                                   |
    +--------------------------------------------------------------------------------------------------------------------+
    | GRANT USAGE ON *.* TO 'user2'@'192.168.212.130' IDENTIFIED BY PASSWORD '*050376F3855A67F5E2C6514FD3130B31006C1276' |
    | GRANT SELECT, INSERT ON `db1`.* TO 'user2'@'192.168.212.130'                                                       |
    +--------------------------------------------------------------------------------------------------------------------+
    2 rows in set (0.00 sec)
    
    mysql> GRANT USAGE ON *.* TO 'user2'@'192.168.212.130' IDENTIFIED BY PASSWORD '*050376F3855A67F5E2C6514FD3130B31006C1276';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>  GRANT SELECT, INSERT ON `db1`.* TO 'user2'@'192.168.212.131';
    Query OK, 0 rows affected (0.00 sec)
    

      查看用户权限

    show grants; 默认ROOT用户
    
    show grants for user2@192.168.133.1;
    

      

  • 相关阅读:
    2017福建夏令营Day7(数论)
    2017福建夏令营Day3(搜索)
    【FZSZ2017暑假提高组Day9】猜数游戏(number)
    【FZSZ2017暑假提高组Day6】bd
    POJ 3660 传递闭包问题
    NOIP 提高组 2002 均分纸牌
    POJ 2387 Til the Cows Come Home
    NOIP 2016 Day2 T1 组合数问题
    06--ubuntu的sqlite安装
    ARM架构与体系学习(二)——3级流水线
  • 原文地址:https://www.cnblogs.com/chyuanliu/p/9365047.html
Copyright © 2020-2023  润新知