美文网首页
mysql 用户

mysql 用户

作者: X1_blog | 来源:发表于2020-05-06 15:16 被阅读0次

添加用户 / 修改密码

    use mysql;
    # 直接创建用户
    create user "test"@"%" identified with mysql_native_password by "123";
    # 修改密码 / 加密插件
    create user "test"@"%" identified by "123";
    alter user 'root'@'%' identified with mysql_native_password by '123';
mysql> select host,user, plugin from user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| %         | 123              | mysql_native_password |
| %         | llbrh            | mysql_native_password |
| %         | test             | mysql_native_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
| localhost | root             | caching_sha2_password |
+-----------+------------------+-----------------------+

删除用户

delete * from user where user="llbrh";

设置默认加密插件

my.ini / my.cnf
[mysqld] 后追加一行
default_authentication_plugin = mysql_native_password

修改远程权限

update user set host="localhost" where user="test";
flush privileges;
# 在另一台设备登录: access denied for user 'test'@'14.145.21.55'(using password :YES)
update user set host="%" where user="test";
flush privileges;
# 在另一台设备登录: 连接成功

相关文章

网友评论

      本文标题:mysql 用户

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