mysql报 Unable to load authentication plugin 'caching_sha2_password'

mysql报Could not get JDBC Connection; nested exception is java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'."

 

问题原因:
这是mysql 8.0版本才出现的问题,原因是mysql 8.0 默认使用 caching_sha2_password 身份验证机制 —— 从原来的 mysql_native_password 更改为 caching_sha2_password。

所以一般这种报错由于本地的MySQL使用的是最新版8.0版本,而打包的项目使用的则是比较低的版本,可以解释说是版本冲突产生的问题。

解决方法:

选择修改身份验证机制:

使用nacivat工具的可以点击 工具——命令列界面进入MySQL的操作界面直接输入命令操作。

没有使用的也可以通过在mysql的bin目录下打开cmd(默认是C:\Program Files\MySQL\MySQL Server 8.0\bin)输入:mysql -uroot -p 接着输入密码 进行登录操作。

登录成功后即进入了命令列界面逐行输入以下代码即可完美解决:

alter user 'root'@'%' identified by 'pass' password expire never;
 
alter user 'root'@'%' identified with mysql_native_password by 'pass';
 
flush privileges;

参考文档:

https://blog.csdn.net/qq_47770103/article/details/120043596

 

posted on 2022-08-08 17:11  让代码飞  阅读(772)  评论(0)    收藏  举报

导航

一款免费在线思维导图工具推荐:https://www.processon.com/i/593e9a29e4b0898669edaf7f?full_name=python