这个错误通常是因为在 MySQL 连接字符串中使用了&allowPublicKeyRetrieval=true参数,而 MySQL Server 版本低于 8.0.4。

解决方法:

  1. 升级 MySQL Server 到 8.0.4 或更高版本。

  2. 在连接字符串中删除&allowPublicKeyRetrieval=true参数。如果您使用的是 MySQL Connector/J 驱动程序,则可以在 URL 中添加以下参数:&useSSL=false&allowPublicKeyRetrieval=true

例如:

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

请注意,删除&allowPublicKeyRetrieval=true参数可能会降低安全性,因为它禁用了使用公钥检索加密密码的功能。如果您需要使用此功能,请升级 MySQL Server 版本。

MySQL 连接报错:Public Key Retrieval is not allowed 的解决方法

原文地址: https://www.cveoy.top/t/topic/mkZi 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录