Mysql8.0中默认的密码验证插件变化了,之前是mysql_native_password,现在是caching_sha2_password。caching_sha2_password提供了更好的性能和更高的密码安全性。
如果mysql版本太低会无法连接到Mysql8.0。报错:
https://www.cndba.cn/Expect-le/article/3087
https://www.cndba.cn/Expect-le/article/3087
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
https://www.cndba.cn/Expect-le/article/3087
The libmysqlclient client library in MySQL 8.0 (8.0.4 or higher). Standard MySQL clients such as mysql and mysqladmin are libmysqlclient-based, so they are compatible as well.
The libmysqlclient client library in MySQL 5.7 (5.7.23 or higher). Standard MySQL clients such as mysql and mysqladmin are libmysqlclient-based, so they are compatible as well.
MySQL Connector/C++ 1.1.11 or higher or 8.0.7 or higher.
MySQL Connector/J 8.0.9 or higher.
MySQL Connector/NET 8.0.10 or higher (through the classic MySQL protocol).
MySQL Connector/Node.js 8.0.9 or higher.
PHP: the X DevAPI PHP extension (mysql_xdevapi) supports caching_sha2_password.
而如果你的客户端版本低于5.7.23,而连接用户又使用了默认的密码验证插件,那么就无法通过该用户连接,只能修改该用户的密码验证插件。
https://www.cndba.cn/Expect-le/article/3087
解决方法如下:https://www.cndba.cn/Expect-le/article/3087
1)
修改某个用户的验证插件
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
https://www.cndba.cn/Expect-le/article/3087
flush privileges;
2)
初始化数据库时,也可以修改默认插件
https://www.cndba.cn/Expect-le/article/3087
bin/mysql –initialize--default-authentication-plugin=mysql_native_password
3)
【推荐】修改配置文件
[mysqld]
https://www.cndba.cn/Expect-le/article/3087https://www.cndba.cn/Expect-le/article/3087
default_authentication_plugin=mysql_native_password
版权声明:本文为博主原创文章,未经博主允许不得转载。
caching_sha2_password