I try to connect MySql database with Java using connector 8.0.11. Everything seems to be ok but I have this exception:
Exception in thread "main" java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
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