How to solve the problem” caching_sha2_password” problem

_mysql_exceptions.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory")

如果是mysql服务器版本大于8.0.4,默认使用caching_sha2_password授权插件,而不是5.6/5.7使用的mysql_native_password进行身份验证。
下面方法更改root账户的远程登录验证插件为mysql_native_password
$ docker exec -it mysql(或CONTAINER ID) mysql -u root -p
输入 root 进入mysql提示符

MySQL [(none)]>
MySQL [(none)]>ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES;
MySQL [(none)]>SELECT User,Host,plugin FROM mysql.user;
MySQL [(none)]>exit
ERROR 1045 (28000): Access denied for user 'root'@'172.17.0.1' (using password: YES)

Solution:
alter user 'root'@'%' identified by 'password';

原因 修改了加密方式之后要把密码修改回去,然后就可以连接了


LEAVE A COMMENT