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
mysql -u root -p
then I ran
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'mypassword';
and also I used
UPDATE user SET authentication_string=password('mypassword') WHERE user='root';
But I'm getting below error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'mypassword'' at line 1
Tutorial MySQL - Configure the authentication via PasswordInstall the MySQL service. Access the MySQL command-line. On the authentication prompt, a password is not required. Verify the authentication plugin and the password configured to the ROOT user account.
Step 2: Navigate to Software > MySQL Upgrade or type “MySQL” into the search bar. You may also find it under SQL Services > MySQL/MariaDB Upgrade. Step 3: Select the version of MySQL you want to upgrade to and click Next. Now follow the upgrade steps, and it'll take care of everything for you.
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.
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.15. You can download it from https://dev.mysql.com/downloads/connector/j/ or specify the right version in Maven/Gradle, etc.
If you are installing Jasper server with MySQL-8. And you're getting above error OR 'Access denied for user root@localhost' while running js-install-ce.bat / js-install-ce.bat test .
Check the plugin column for ‘root’ user, it has to be ‘mysql_native_password’. If the plugin value is ‘caching_sha2_password’ then you need to run update query: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
OR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With