java.sql.SQLException: Unable to load authentication plugin ‘caching_sha2_password‘.避坑指南

Posted 明明如月学长

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.sql.SQLException: Unable to load authentication plugin ‘caching_sha2_password‘.避坑指南相关的知识,希望对你有一定的参考价值。

最近遇到了 java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.这个报错。

再此分享,希望能够对其他人有帮助,

主要原因8.x版本的验证模块和之前版本不同:

5.x版本是:default_authentication_plugin=mysql_native_password

8.x版本就是:default_authentication_plugin=caching_sha2_password

网上的主要解决方案是:

1 修改mysql的配置文件为旧的模块

2 运行命令将某个用户的验证模块改为旧版的模块

但是我更建议用另外一种方案,更新mysql驱动的jar版本,可以修改为8.0.11版本

因为MySQL的版本升级就是为了更加安全,不应该为了迁就旧的驱动而修改验证插件。

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.11</version>
</dependency>

 

如果文章对你有帮助,欢迎点赞,关注,你的鼓励是我创作的最大动力!!

以上是关于java.sql.SQLException: Unable to load authentication plugin ‘caching_sha2_password‘.避坑指南的主要内容,如果未能解决你的问题,请参考以下文章

java.sql.SQLException: SQL 语句在 org.hsqldb.jdbc.JDBCUtil.sqlException 处关闭

Oracle DB:java.sql.SQLException:关闭连接

Cause: java.sql.SQLException: 请求的转换无效 ; uncategorized SQLException for SQL []; SQL state [99999]; er

java.sql.SQLException: ORA-00604: 递归 SQL 级别 1 发生错误

Java:Sqlexception:位置不支持的 SQL92 令牌:178

java.sql.SQLException:接近“on”:语法错误问题