mybatis报错java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
时间: 2023-11-17 10:01:40 浏览: 295
这个错误通常是由于MySQL 8.0版本的更改所导致的。在MySQL 8.0中,默认情况下禁用了从服务器获取公钥的功能,需要手动启用。
解决方法如下:
1. 在连接MySQL时,添加allowPublicKeyRetrieval=true参数,例如:
jdbc:mysql://localhost:3306/mydatabase?allowPublicKeyRetrieval=true
2. 修改MySQL配置文件,将mysql_native_password插件改为caching_sha2_password。具体步骤如下:
a. 登录MySQL,执行以下命令:
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'your_password';
注意:将'your_password'替换为你的MySQL密码。
b. 修改MySQL配置文件my.cnf或my.ini,在[mysqld]下添加以下内容:
default_authentication_plugin=caching_sha2_password
注意:如果已经存在default_authentication_plugin参数,将其修改为caching_sha2_password即可。
3. 如果以上方法都无法解决问题,可以尝试升级MySQL驱动程序到8.0.11以上版本。
阅读全文
相关推荐

















