项目中数据库mysql从5.7升到8.0后启动报错:java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

经过查找文档,找到两个属性

serverRSAPublicKeyFile:放置服务器上的公钥文件位置

allowPublicKeyRetrieval:允许从服务器上获取公钥

Note

To authenticate accounts with the caching_sha2_password plugin, either a secure connection to the server using SSL or an unencrypted connection that supports password exchange using an RSA key pair (enabled by setting one or both of the connecting properties allowPublicKeyRetrieval and serverRSAPublicKeyFile) must be used.

大致意思是说使用caching_sha2_password插件的,这两个属性必须要设置一个。

If the MySQL server's default authentication method was SHA256 but neither one of the Connector/J connection properties allowPublicKeyRetrieval and serverRSAPublicKeyFile was set, the authentication failed with a TransientConnectionException, complaining that the public key could not be retrieved. With this fix, authentication continues in the situation, allowing other enabled authentication methods to be tried. (Bug #20433047, Bug #75670)

如果两个都没有设置,会抛public key could not be retrieved异常。

经过在网上搜索和查文档有两个解决方法:

1. 将allowPublicKeyRetrieval设为true,允许从服务器上获取公钥文件

jdbcUrl=jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true

2. 设置公钥文件位置serverRSAPublicKeyFile:

将服务器上数据目录下的public_key.pem拷至本地,连接上加上此属性 serverRSAPublicKeyFile=/data%2Fpublic_key.pem, 文件:/data/public_key.pem, %2F为/,%3A为:

jdbcUrl=jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=GMT%2B8&serverRSAPublicKeyFile=/data%2Fpublic_key.pem

以上两种方法都可以解决。

mysql 8.0 解决报错Public Key Retrieval is not allowed相关推荐

  1. java mysql的一次报错,Public Key Retrieval is not allowed

    文章目录 记录mysql的一次报错,先记录问题,稍后再排查问题所在 Exception 记录mysql的一次报错,先记录问题,稍后再排查问题所在 Exception 2022-09-28 10:58: ...

  2. MySQL连接报错Public Key Retrieval is not allowed错误

    Mysql 8.x版本连接时报错 java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed 可能 ...

  3. MySQL8报错:Public Key Retrieval is not allowed

    前言 连接MySQL数据库的时候,报错内容如下:"Public Key Retrieval is not allowed". 问题分析 mysql 8.0 默认使用 caching ...

  4. mybatis运行报错java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

    mybatis运行报错1 报错:java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed 解决方 ...

  5. 解决java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

    解决java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed 在连接数据库的url中,加上all ...

  6. 解决mybatis java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

    Mybatis报错 Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectio ...

  7. Public Key Retrieval is not allowed(已解决)

    Public Key Retrieval is not allowed(已解决) 在url的连接中加上allowPublicKeyRetrieval=true

  8. Public Key Retrieval is not allowed解决

    记录Public Key Retrieval is not allowed 文章目录 记录Public Key Retrieval is not allowed 一.导致"Public Ke ...

  9. java.sql.SQLNonTransientConnectionException Public Key Retrieval is not allowed

    报错信息 2022-03-18 17:46:43.428 ERROR 20704 - [eate-1849941462] com.alibaba.druid.pool.DruidDataSource ...

最新文章

  1. 斗争程序猿(三十八)——历史朝代大学(两)——我与数据库的故事
  2. tcpdump 命令的个常用选项:一
  3. 【玩转数据】让您的PPT数据图表炫酷起来吧!
  4. 情人节,你刚表白,而我已经开始选哪里拍婚纱照了~
  5. BTC引领市场多头情绪爆发 BCH筑底完成望成上涨新风口
  6. Centos 6.4 搭建LANMP一键安装版
  7. 编译安装 PHP 扩展 - 含 swoole 扩展安装和升级
  8. 普及一下equals和==的区别的误区
  9. python基础===将Flask用于实现Mock-server
  10. 如何处理SAP CRM错误消息the item category X is not permitted
  11. ACM 会场安排问题
  12. 使用Windows Performance Monitor进行SQL Server性能调整
  13. python中paramiko模块_如何使用python中paramiko模块?
  14. checking for spandsp >= 3.0... configure: error: no usable spandsp; please install spandsp3 devel pa
  15. 计算机电池电源转换,整套解决方案:笔记本电脑的外部电源和电池如何实现无缝切换?...
  16. 【day23】The field file exceeds its maximum permitted size of 1048576 bytes.
  17. pr cc 2018的快捷键整理
  18. 智能交通:电子警察系统技术实施方案(ppt)
  19. 人工智能机器人发展前景,使用/教程/实例
  20. phpwind 安装教程图文说明

热门文章

  1. DSPIC33F BLDC 开发板全套资料(无感/有感/方波/正弦波控制)
  2. 我的小金库(跬步千里)
  3. linux操作redis
  4. 2011年5月20日
  5. 前端知乎:关于阮一峰博客《学习Javascript闭包》章节中最后两个思考题
  6. 使用MuMu模拟器自带adb抓取apk日志文件
  7. vue笔记 短时间内处理多次请求,只执行最后一次请求问题
  8. 在linux下查看.caj文档
  9. SV中的采样和数据驱动
  10. 【Proteus仿真】【51单片机】竞赛抢答器设计