Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection Spring Boot-MySql : Public Key Retrieval is not allowed

Tags:

java

mysql

spring

I ran one of my apps back in early June of this year with no problems. After trying it again today, I get the following error in the console :

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed

Any ideas on how to fix?

I've researched this but have found nothing specific to Spring Boot apps.

Settings in applications.properties :

spring.mvc.view.prefix=/WEB-INF/views/

spring.mvc.view.suffix=.jsp

spring.datasource.url = jdbc:mysql://localhost:3306/testdb?verifyServerCertificate=false&useSSL=false&requireSSL=false&useJDBCCompliantTimezoneShift=true&serverTimezone=UTC
spring.datasource.username = root
spring.datasource.password = 


spring.jpa.show-sql = true 


spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update


spring.jpa.hibernate.naming.implicit-strategy = org.hibernate.cfg.ImprovedNamingStrategy

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed

like image 619
wallwalker Avatar asked Aug 08 '19 15:08

wallwalker


People also ask

How do I fix public key retrieval is not allowed?

Update MySQL JDBC Driver Version I think the best way to fix the error “Public Key Retrieval is not allowed” is updating the version of my-sql-connector-java to the version compatible with the version of MySQL server. For example, if your MySQL server version is 8.0.

What is allowPublicKeyRetrieval?

We need to set AllowPublicKeyRetrieval=true to allow the client to automatically request the public key from the server. allowPublicKeyRetrieval=true. You can also disable SSL and also suppress the SSL errors: useSSL=false.


2 Answers

use the following

jdbc:mysql://localhost:3306/payphone?useSSL=false&useJDBCComplaintTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
like image 68
Sheriff Adebisi Avatar answered Oct 20 '22 20:10

Sheriff Adebisi


Possible solutions :

1 - Check if the mysql uses port 3306 and it's alive.

2 - Make sure your mysql username and password is correct.

3 - If you are using Mysql 8 and above then you may check authentication plugin change form this link

like image 45
lutfucan Avatar answered Oct 20 '22 21:10

lutfucan