美文网首页
Mysql创建新用户并赋予权限

Mysql创建新用户并赋予权限

作者: 敬子v | 来源:发表于2021-06-14 20:20 被阅读0次

    1.创建用户

    create user '用户名'@'localhost'identified by'密码';

    mysql> create user 'bwj'@'localhost'  identified by'666666';
    Query OK, 0 rows affected (0.00 sec)
    

    2.赋予全部权限

    grant all on 权限 to 用户名@'localhost' identified by "密码";

    mysql> grant all on *.* to bwj@'localhost' identified by "666666";
    Query OK, 0 rows affected, 1 warning (0.01 sec)
    

    3.查看用户权限

    show grants for '用户名'@'localhost';

    mysql> show grants for 'bwj'@'localhost';
    +--------------------------------------------------+
    | Grants for bwj@localhost                         |
    +--------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'bwj'@'localhost' |
    +--------------------------------------------------+
    1 row in set (0.00 sec)
    
    

    4.查看用户名

    select user,host from mysql.user;

    mysql> select user,host from mysql.user;
    +------------------+-----------+
    | user             | host      |
    +------------------+-----------+
    | bwj              | localhost |
    | debian-sys-maint | localhost |
    | mysql.session    | localhost |
    | mysql.sys        | localhost |
    | root             | localhost |
    | www              | localhost |
    +------------------+-----------+
    6 rows in set (0.00 sec)
    
    

    写作不易,望多多支持、点赞、收藏、赞赏!

    希望用心的制作能对您有所帮助!

    相关文章

      网友评论

          本文标题:Mysql创建新用户并赋予权限

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