【连接MySQL】java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.

因为SQL8.0以后改变了身份验证插件,验证方式由mysql_native_password变为caching_sha2_password,打开 my.ini (或者my.cofg) 可以看到变更了 5.7及其以前的方式

解决方法

法一. 进入MySQL以后

ALTER USER your_user_name IDENTIFIED WITH mysql_native_password;

例如:username=student,password=123456

ALTER USER 'student'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

法二. 打开pom.xml文件,更改依赖。注意mysql版本要与自己所用一致,我使用的mysql版本为8.0.13。

<dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>8.0.13</version>
</dependency>

注:查看mysql版本方法:

mysql -V

你可能感兴趣的:(日常BUG收集)