MySQL 连接出现 Authentication plugin 'caching_sha2_password' cannot be loaded

380 阅读1分钟

MySQL 连接出现 Authentication plugin 'caching_sha2_password' cannot be loaded

最近使用docker安装了mysql,在容器中访问mysql,可以正常访问

image.png

通过navicat访问报错,报错原因是mysql8之前的版本中的加密规则是mysql_native_password,而mysql8之后使用的加密规则是caching_sha2_password

image.png

解决方法。修改账户密码加密规则并更新用户名密码

1.修改加密规则,并更新用户密码

alter user 'root'@'localhost' identified by 'password' password expire never;

alter user 'root'@'localhost' identified with mysql_native_password by'root';

2.刷新权限

flush privileges;

一顿操作后,结果还是报错,通过查询root用户的密码加密规则,发现改的是本地连接时的密码加密 规则,并不是远端连接时的密码加密规则

select user, host, plugin from user;

image.png

修改远程连接时的用户密码加密规则

alter user 'root'@'%' identified with mysql_native_password by '654321';

image.png

连接成功!