mysql 用户

2020-05-06  本文已影响0人  X1_blog

添加用户 / 修改密码

    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;
# 在另一台设备登录: 连接成功
上一篇下一篇

猜你喜欢

热点阅读