Connection Java – MySQL : Public Key Retrieval is not allowed

We Are Going To Discuss About Connection Java – MySQL : Public Key Retrieval is not allowed. So lets Start this Java Article.

Connection Java – MySQL : Public Key Retrieval is not allowed

  1. Connection Java – MySQL : Public Key Retrieval is not allowed

    Right click your connection, choose “Edit Connection”
    On the “Connection settings” screen (main screen) click on “Edit Driver Settings”
    Click on “Connection properties”
    Right click the “user properties” area and choose “Add new property”

  2. Connection Java – MySQL : Public Key Retrieval is not allowed

    Right click your connection, choose “Edit Connection”
    On the “Connection settings” screen (main screen) click on “Edit Driver Settings”
    Click on “Connection properties”
    Right click the “user properties” area and choose “Add new property”

Solution 1

You should add client option to your mysql-connector allowPublicKeyRetrieval=true to allow the client to automatically request the public key from the server. Note that allowPublicKeyRetrieval=True could allow a malicious proxy to perform a MITM attack to get the plaintext password, so it is False by default and must be explicitly enabled.

https://mysql-net.github.io/MySqlConnector/connection-options/

you could also try adding useSSL=false when you use it for testing/develop purposes

example:

jdbc:mysql://localhost:3306/db?allowPublicKeyRetrieval=true&useSSL=false

Original Author jtomaszk Of This Content

Solution 2

For DBeaver users:

  1. Right click your connection, choose “Edit Connection”

  2. On the “Connection settings” screen (main screen) click on “Edit Driver Settings”

  3. Click on “Connection properties”

  4. Right click the “user properties” area and choose “Add new property”

  5. Add two properties: “useSSL” and “allowPublicKeyRetrieval”

  6. Set their values to “false” and “true” by double clicking on the “value” column

Original Author Javier Aviles Of This Content

Solution 3

When doing this from DBeaver I had to go to “Connection settings” -> “SSL” tab and then :

  • uncheck the “Verify server certificate”
  • check the “Allow public key retrival”

This is how it looks like.
DBeaver configuration

Note that this is suitable for local development only.

Original Author Michał Krzywański Of This Content

Solution 4

Use jdbc url as :

jdbc:mysql://localhost:3306/Database_dbName?allowPublicKeyRetrieval=true&useSSL=False;

PortNo: 3306 can be different in your configuation

Original Author susan097 Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment