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;

连接成功


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM