MySQL-错误:2059 - Authentication plugin 'caching_sha2_password' cannot be loaded

MySQL-错误:2059-Authentication plugin 'caching_sha2_password' cannot be loaded

一 现象

使用docker镜像创建容器后,mysql测试连接不成功

二 原因

网上查询得到原因:在mysql8之前的版本中加密规则为mysql_native_password,而在mysql8以后的加密规则为caching_sha2_password

确认docker镜像创建容器的mysql为mysql8之后的版本

三 解决方案

将mysql的加密规则改回来

grant all on *.* to 'root'@'%';  # 授权

flush privileges;

alter user 'root'@'localhost' identified by '123456' password expire never;  # 修改加密规则

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';  # 修改密码

flush privileges;

连接成功

猜你喜欢

转载自www.cnblogs.com/king-of-puppets/p/13179460.html