【MySQL异常解决】Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not

Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not allowed solution

1. Background description

When the Java Spring Boot project starts, an error is reported when connecting to the database console:

Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not allowed
insert image description here

Two, the solution

The solution was found under a MySQL Forums on the MySQL official website . The solution is as follows:

Just add the following keyValue to spring.datasource.url.

allowPublicKeyRetrieval=true

As shown below:

insert image description here

3. Reason analysis

You can view the official documentation: MySqlConnector -> Connection Options -> Other Options

insert image description here

The translation is:
if the user uses sha256_password authentication, the password must be protected by the TLS protocol during transmission, but if the RSA public key is not available, the public key provided by the server can be used; the RSA public key of the server can be specified through ServerRSAPublicKeyFile in the connection, Or AllowPublicKeyRetrieval=True parameter to allow the client to obtain the public key from the server; but it should be noted that AllowPublicKeyRetrieval=True may cause malicious agents to obtain plaintext passwords through man-in-the-middle attacks (MITM), so it is disabled by default and must be explicitly enabled .

This article is over!

Guess you like

Origin blog.csdn.net/weixin_44299027/article/details/131766486