MySQL 8.0 配置mysql_native_password身份验证插件的密码

MySQL 8.0 配置mysql_native_password身份验证插件的密码

mysql8.0的默认密码验证不再是password。所以在创建用户时,create user 'username'@'%' identified by 'password'; 客户端是无法连接服务的。

 

方法一:

登录MySQL后输入:

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

FLUSH PRIVILEGES;

 

方法二:

编辑my.cnf文件,更改默认的身份认证插件。比如说:

vim /data/mysql/mysql_3306/my_3306.cnf

# 在[mysqld]中添加下边的代码
default_authentication_plugin=mysql_native_password

这个需要重启服务才生效。

 

mysql> select user,host,plugin from mysql.user;        
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| bak              | %         | mysql_native_password |
| monitor          | %         | mysql_native_password |
| repuser          | %         | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| repuser          | localhost | caching_sha2_password |
| root             | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
8 rows in set (0.00 sec)

 




posted @ 2019-12-30 11:05  davie2020  阅读(39029)  评论(2编辑  收藏  举报