美文网首页
Linux之Mysql相关指令

Linux之Mysql相关指令

作者: YBshone | 来源:发表于2018-02-26 10:56 被阅读0次

    查询用户名

    >mysql use mysql;
    Database changed
    >mysql select user,host from user

    +———+———————–+
    | user    | host                  |
    +———+———————–+
    | root    | [127.0.0.1]             |
    |         | localhost             |
    | root    | localhost             |
    |         | localhost.localdomain |
    | root    | localhost.localdomain |
    +———+———————–+
    7 rows in set (0.00 sec)
    

    mysql> show grants for root@’localhost’;

    +——————————————————+
    | Grants for root@localhost                                           |
    +——————————————————+
    | GRANT ALL PRIVILEGES ON *.* TO ‘root’@'localhost’ WITH GRANT OPTION |
    +——————————————————+
    1 row in set (0.00 sec)
    

    mysql>
    mysql> select db,user ,host from db;

    +———+——+————–+
    | db      | user | host         |
    +———+——+————–+
    | test    |      | %            |
    | test\_% |      | %            |
    | db      | test | 172.20.1.124 |
    +———+——+————–+
    3 rows in set (0.00 sec)
    

    mysql>

    Grant 用法

    mysql> GRANT <privileges> ON <what>
    -> TO <user> [IDENTIFIED BY "<password>"]
    -> [WITH GRANT OPTION];

    例如:GRANT USAGE ON . TO ‘discuz’@'localhost’ IDENTIFIED BY PASSWORD ’123456′;</pre>

    相关文章

      网友评论

          本文标题:Linux之Mysql相关指令

          本文链接:https://www.haomeiwen.com/subject/otuexftx.html