一、问题

因停电检修,今天重启服务器后,再启动jboss就报错“MySQLNonTransientConnectionException: Public Key Retrieval is not allowed”,jboss无法获取对数据源的JDBC连接。

二、解决过程

百度一下,先说是旧版JDBC驱动的bug,于是从maven中央库下载最新的mysql-connector-8.0.11.jar,替换后修改jboss的modle说明、将配置文件中的driver-class改为'com.mysql.cj.jdbc.Driver',但错误依旧。随后发现8.0.11版与hibernate不匹配,又改回原来的5.1.46。

继续百度,说是需修改default_authentication_plugin设置,于是修改my.ini,增加[mysqld] default_authentication_plugin=mysql_native_password,重启mysql 8,错误依旧。

继续百度,说是仍需修改用户的密码加密方式,于是在mysql命令行执行:ALTER USER 'myuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypassword';,这次虽仍报错,但错误提示变成“InvalidConnectionAttributeException: The server time zone value '<乱码>' is unrecognized or represents more than one time zone. ……”。

继续百度,说是在jdbc连接串需指定time zone,于是修改jboss配置文件中的connection-url,在最后增加serverTimezone=Asia/Shanghai,重启jboss,终于过关。

三、总结

  • 更换mysql的jdbc驱动,但其实从 5.1.37已经更新过这个bug,一般不需要;
  • 修改my.ini(Linux则是my.cnf),增加[mysqld] default_authentication_plugin=mysql_native_password;
  • 在mysql命令行执行:ALTER USER 'myuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypassword';
  • 在jdbc连接串指定time zone。

四、疑问

问题虽然解决了,但仍存在几个疑问:

  • 为什么停电重启前一切正常?
  • 为避免SSL,配置文件中的connection-url中加了useSSL=false,难道与这有关系?

Jdbc连接MySQL 8时报错“MySQLNonTransientConnectionException: Public Key Retrieval is not allowed”的更多相关文章

  1. mysql遇到java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

    在连接数据库的url中,加上allowPublicKeyRetrieval=true from:https://blog.csdn.net/Gushiyuta/article/details/9323 ...

  2. JDBC链接数据库MySQL 8.0 Public Key Retrieval is not allowed 错误的解决方法

    现象 Mybatis和Spring框架整合过程中报 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Publ ...

  3. 用Navicat Premium 连接mysql数据库时报错 -- 1130 Host xxxx is not allowed to connect to this MySQL server

    用Navicat Premium 连接mysql数据库时报错 报错原因:此时的MySQL默认不能远程连接. 解决方案:修改MySQL配置 具体步骤: 1.登陆服务器,进入数据库 mysql -uroo ...

  4. 关于JDBC连接数据库时出现的Public Key Retrieval is not allowed错误

    问题描述 最近在学习MyBatis框架,参考官方的文档通过配置文件的方式已经实现了通过Configuration配置文件和mapper映射文件访问mysql8数据库,于是想试试不使用XML文件去构建S ...

  5. 远程连接mysql数据库时报错: 错误代码 2003不能连接到MySQL服务器在*.*.*.*(111)

    在测试服务器上安装完mysql后, 服务器自己访问没有问题, 但是本地通过sql客户端连接时报错: 错误代码 2003不能连接到MySQL服务器在*.*.*.*(111).在网上查了一些资料,解决方案 ...

  6. Public Key Retrieval is not allowed

    链接MySQL数据库报错: 数据库连接url中添加对应属性的支持.allowPublicKeyRetrieval=true&useSSL=false url: jdbc:mysql://loc ...

  7. Myeclipse连接Mysql数据库时报错:Error while performing database login with the pro driver:unable

    driver template: Mysql connector/j(下拉框进行选择) driver name: 任意填,最好是数据库名称,方便查找 connection URL: jdbc:mysq ...

  8. Nacos使用 MySQL 8.0 提示Public Key Retrieval is not allowed

    原因如下(参考官网给出的连接选项): 如果用户使用了 sha256_password 认证,密码在传输过程中必须使用 TLS 协议保护,但是如果 RSA 公钥不可用,可以使用服务器提供的公钥:可以在连 ...

  9. spring boot MySQL Public Key Retrieval is not allowed

    建议在链接url处添加对应的属性 jdbc:mysql://localhost:3306/book?allowPublicKeyRetrieval=true&useSSL=false 

随机推荐

  1. 人工智能计算器AI Calculator 3.3.0 具体破解思路&amp;教程

    人工智能计算器AI Calculator 3.3.0 具体破解思路&教程 [文章标题]:人工智能计算器AI Calculator 3.3.0 具体破解思路&教程 [文章作者]: Eri ...

  2. JMeter--聚合报告之 90% Line 正确理解

    90% Line 参数正确的含义: 虽然,我的上面理解有一定的道理,显然它(90% 用户的响应时间)是错误的.那看看JMeter 官网是怎么说的? 90% Line - 90% of the samp ...

  3. jmeter--元件的作用域与执行顺序

    1.元件的作用域 JMeter中共有8类可被执行的元件(测试计划与线程组不属于元件),这些元件中,取样器是典型的不与其它元件发生交互作用的元件,逻辑控制器只对其子节点的取样器有效,而其它元件(conf ...

  4. P2P借款的几种情况

    借款,至少出现2种人,借款人和出借人.根据人的性质,企业和个人,分成4种情况. 企业-个人,企业-企业,个人-企业,个人-个人. P2P平台可能出现几种情况: 个人-个人 2种情况:   a. 借款人 ...

  5. 微信小程序实现运动步数排行(可删除)

    wxml <!-- 向左滑动删除功能 --> <view class="item-box"> <view class="items" ...

  6. 【习题 5-8 UVA - 230】Borrowers

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map+set写个模拟就好. 3个区域 书架.桌子.别人的手上. 其中前两个区域的书都能借出去. [代码] #include &l ...

  7. 【习题5-1 UVA - 1593】Alignment of Code

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟题,每一列都选最长的那个字符串,然后后面加一个空格就好. 这个作为场宽. 模拟输出就好. [代码] #include <b ...

  8. Learn from Architects of Buildings

     Learn from Architects of Buildings Keith Braithwaite Architecture is a social act and the material ...

  9. [WASM] Read WebAssembly Memory from JavaScript

    We use an offset exporting function to get the address of a string in WebAssembly memory. We then cr ...

  10. 如何在 Linux 中统计一个进程的线程数

    编译自:http://ask.xmodulo.com/number-of-threads-process-linux.html作者: Dan Nanni原创:LCTT https://linux.cn ...