The error
Public Key Retrieval is not allowed
occurs when MySQL’s caching_sha2_password authentication plugin is used, and the client (e.g., DBeaver) is not allowed to automatically fetch the public key from the server for secure password exchange.
This is common when connecting to a MySQL 8+ container using clients like DBeaver or JDBC.
✅ Fix Options
Option 1 — Add allowPublicKeyRetrieval=true to JDBC URL (recommended for local/dev)
-
In DBeaver, open your MySQL connection settings.
-
Go to "Driver properties" tab.
-
Add or modify the property:
-
Also ensure:
(or
trueif you are using SSL properly configured) -
Example full JDBC URL:
Option 2 — Change authentication plugin on MySQL user
If you have access to the MySQL server and prefer not to allow key retrieval:
Run this inside the container or via MySQL CLI:
This changes the user to use the older mysql_native_password plugin (compatible with all clients).
Option 3 — Use latest MySQL driver
Make sure your DBeaver is using the latest MySQL JDBC driver:
-
Go to DBeaver → Database → Driver Manager → MySQL.
-
Click "Edit Driver" → "Download/Update".
-
Update to the latest driver version.
💡 Notes
-
allowPublicKeyRetrieval=trueis safe in local or test environments.
In production, use SSL certificates or configure a trusted key exchange. -
This issue is particularly common with MySQL 8 Docker images that use the
caching_sha2_passwordplugin by default.