Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3996)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2137)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:154)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:145)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:169)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
at org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl.getIsolatedConnection(DdlTransactionIsolatorNonJtaImpl.java:43)
即使更新了mysql密码,我也会收到此错误。我在一些帖子中读到mysql有一个新的缓存机制,并且所有客户端都需要运行以下我已经做过的但仍然是同样的错误:
update user set authentication_string='test' where user='root';
flush privileges
答案 0 :(得分:5)
第1步:使用SELECT version();
查询来检查当前Mysql的版本。
第2步:检查Maven中Mysql jdbc驱动程序的版本或Mysql依赖项。
第3步:升级Mysql的jar版本或maven依赖版本。
答案 1 :(得分:3)
可以使用以下步骤纠正此问题:-
步骤1:-在mysql中运行以下查询并重新启动(对于版本> 8.0,用户名在此处为root)
使用“ yourpassword”通过mysql_native_password标识ALTER USER'root'@'localhost';
步骤2:-通过运行select version()来检查mysql的版本;在mysql中
the version of mysql in pom.xml should be same as the version of mysql installed (mine is 8.0.14)
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.14</version>
步骤3:-如果maven存储库中没有mysql-connector jar文件,则可以下载8.0.14版本的jar并将其粘贴到存储库中
$ \。m2 \ repository \ mysql \ mysql-connector-java \ 8.0.14
步骤4:-更新您的Maven项目
步骤5:-在config.xml中检查driverClassName,它应该是“ com.mysql.cj.jdbc.Driver”。
答案 2 :(得分:1)
您必须使用MySQL的OLD_PASSWORD函数更新数据库用户的密码。 SOLUTION
例如:
[rajesh-tpl-01@home ~]$ mysql -u root -p mysql
Enter password:
mysql> update user set password=OLD_PASSWORD('password') WHERE
user='username';
Query OK, 0 rows affected (0.02 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
答案 3 :(得分:1)
在项目的lib文件夹中检查mysql-connector-java-version.jar(例如:mysql-connector-java-8.0.11.jar),并进行相应升级。
答案 4 :(得分:1)
我已经完成了提示信息。我曾在pom.xml
中进餐:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
并更改为latest version:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.12</version>
</dependency>
答案 5 :(得分:0)
只需将mysql-connector-java更新到最新版本,就不需要其他任何事情
答案 6 :(得分:0)
问题出在mysql-connector-java版本5.1.6。尝试升级到5.1.44版。为我工作。我使用了以下依赖版本:
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.44'
答案 7 :(得分:0)