美文网首页程序员
mysql安装后操作(一)

mysql安装后操作(一)

作者: 六月繁花开 | 来源:发表于2019-04-18 11:02 被阅读0次

    https://juejin.im/post/5cad39b3f265da03502b1c0a#heading-5

    1. 查看用户:

    mysql> use mysql;
    mysql> select host,user from mysql.user;
    
    +------------+------+
    | host       | user |
    +------------+------+
    | 127.0.0.1  | root |
    | ::1        | root |
    | localhost  |      |
    | localhost  | root |
    | server.gao |      |
    | server.gao | root |
    +------------+------+
    

    2. 创建用户:

    mysql> create user 'usrabc'@'%' identified by 'usrabc';
    
    mysql> select host,user from mysql.user;
    +------------+--------+
    | host       | user   |
    +------------+--------+
    | %          | usrabc |
    | 127.0.0.1  | root   |
    | ::1        | root   |
    | localhost  |        |
    | localhost  | root   |
    | server.gao |        |
    | server.gao | root   |
    +------------+--------+
    

    3. 查看当前登录用户

    mysql> select user();
    +----------------+
    | user() |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.00 sec)
    

    4. 查看当前数据库

    mysql> select database();
    +--------------------+
    | database() |
    +--------------------+
    | information_schema |
    +--------------------+
    1 row in set (0.00 sec)
    

    4. 删除用户

    mysql> use mysql;
    mysql> DELETE FROM user WHERE HOST='localhost' AND User="test2";
    +------------+------+
    | host       | user |
    +------------+------+
    | 127.0.0.1  | root |
    | ::1        | root |
    | localhost  |      |
    +------------+------+
    query OK;
    

    相关文章

      网友评论

        本文标题:mysql安装后操作(一)

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