链接MySQL报错2059 -Authentication plugin ‘caching sha2 password‘ cannot be loaded解决方案

06-01 1833阅读

1.报错内容: 

2059 -Authentication plugin 'caching sha2 password' cannot be loaded

2.报错截图:

链接MySQL报错2059 -Authentication plugin ‘caching sha2 password‘ cannot be loaded解决方案

3.原因分析:

如上图的报错提示可知,报错原因是caching_sha2_password不能加载。在MySQL 8.0及以上版本中,默认的用户密码认证插件是'caching_sha2_password',而在MySQL 5.7及以下版本中,默认的是'mysql_native_password'。如果客户端不支持'caching_sha2_password',就会出现这个错误。

因为8.0之后mysql更改了密码的加密规则,而目前已有的客户端连接软件还不支持Mysql8新增加的加密方式caching_sha2_password,所以我们需要修改用户的加密方式,将其改为老的加密验证方式。

4.解决方案分析:

法1:升级客户端:确保你的数据库客户端支持'caching_sha2_password'。

法2:修改用户的密码认证插件:可以将用户的密码认证插件改为'mysql_native_password'。

下面将以第二种解决方案为例进行演示:

(1)win+R调出运行框,输入cmd,进入命令提示符界面,cd进入MySQL安装目录并登录到MySQL

cd C:\Program Files\MySQL\MySQL Server 8.0\bin
mysql -u root -p

链接MySQL报错2059 -Authentication plugin ‘caching sha2 password‘ cannot be loaded解决方案

(2)修改加密规则,更新密码并刷新

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

此处的password替换成自己的数据库密码(此处密码为自己设置的,我当前修改的密码为:password)

alter user root@localhost identified with mysql_native_password by 'password';
flush privileges

链接MySQL报错2059 -Authentication plugin ‘caching sha2 password‘ cannot be loaded解决方案

 (3)本地客户端测试--连接成功!链接MySQL报错2059 -Authentication plugin ‘caching sha2 password‘ cannot be loaded解决方案

免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们。

目录[+]

取消
微信二维码
微信二维码
支付宝二维码