考虑升级MySQL客户端

考虑升级MySQL客户端

本文介绍了错误:客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行JDBC程序时,连接数据库时出现以下错误:

While executing a JDBC program, I get the following error while connecting to database:

Exception in thread "main"
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client does
not support authentication protocol requested by server; consider upgrading
MySQL client
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at main.java.MyFirstJdbcProgram.readDataBase(MyFirstJdbcProgram.java:23)
at main.java.Main.main(Main.java:6)

当我研究这个时,我知道下面的内容错误是因为我需要向用户授予权限,所以按照

When I researched this, I got to know that the below error is because I need to grant the privileges to the user, so follow


  1. mysql -u root -p

  2. 然后输入密码

  3. 然后我跑

  1. mysql -u root -p
  2. then entered the password
  3. then I ran

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'mypassword';

我还使用了

UPDATE user SET authentication_string=password('mypassword') WHERE user='root';


但我收到以下错误


推荐答案

发生此错误的原因是您使用的是MySQL Connector / J 5.1.45或更早版本。 MySQL 8引入了一种新的身份验证机制( caching_sha2_password ),在这些版本的驱动程序中不支持。

This error occurs because you are using MySQL Connector/J 5.1.45 or earlier. MySQL 8 introduced a new authentication mechanism (caching_sha2_password) that is not supported in those versions of the driver.

你将需要升级到MySQL Connector / J 5.1.46或更高版本。在编写本文时,最新版本的MySQL Connector / J驱动程序是8.0.11。

You will need to upgrade to MySQL Connector/J 5.1.46 or higher. The latest version of the MySQL Connector/J driver at time of writing is 8.0.11.

这篇关于错误:客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 21:24