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
 

解决方案

①更新mysql驱动的jar版本,修改为8.0.11版本

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

②修改数据库配置driver为com.mysql.cj.jdbc.Driver(可以不改),url加上serverTimezone=UTC(这两个是8.x与5.x不同的配置)

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
青葱年少的头像青葱年少普通用户
上一篇 2023年12月15日
下一篇 2023年12月15日

相关推荐