Mysql8.0中默认的密码验证插件变化了,之前是mysql_native_password,现在是caching_sha2_password。caching_sha2_password提供了更好的性能和更高的密码安全性。
如果mysql版本太低会无法连接到Mysql8.0。报错:
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
官方给出了客户端和连接器的兼容版本:
- 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,而连接用户又使用了默认的密码验证插件,那么就无法通过该用户连接,只能修改该用户的密码验证插件。
解决方法如下:
1) 修改某个用户的验证插件
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
flush privileges;
2) 初始化数据库时,也可以修改默认插件
bin/mysql –initialize --default-authentication-plugin=mysql_native_password
3) 【推荐】修改配置文件
[mysqld]
default_authentication_plugin=mysql_native_password
版权声明:本文为博主原创文章,未经博主允许不得转载。
caching_sha2_password