Java连接Mysql报错:javax.net.ssl.SSLException: Received fatal alert: internal_error

大致报错日志如下:

The last packet successfully received from the server was 11 milliseconds ago.  The last packet sent successfully to the server was 10 milliseconds ago.
    at sun.reflect.GeneratedConstructorAccessor275.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)
    at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:203)
    at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4901)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2191)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2222)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2017)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:779)
    at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
    at sun.reflect.GeneratedConstructorAccessor147.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    ... 62 more
Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket...

原因:

看了各类博客说,Mysql在5.7.43版本加大了对隐私的保护。默认 useSSL = true值防止对数据库的随意修改。

解决方案:

1、jdbc连接后面加useSSL=false (未成功)

2、关闭mysql的SSL(成功解决

在MySQL配置文件(/etc/my.conf)中添加disable_ssl和skip_ssl参数,如下:

Java连接Mysql报错:javax.net.ssl.SSLException: Received fatal alert: internal_error_第1张图片

重启mysql服务

测试正常,坑已填平!!!

参考文章:

https://blog.csdn.net/guoheng_123/article/details/132358920文章浏览阅读2.4k次。前几天为了修复MySQL数据库漏洞,项目上从5.7.41版本升级到了5.7.43,今天在使用kettle时发现数据库突然连不上了,测试连接报如下错误: Error connecting to database: (using class org.gjt.mm.mysql.Driver)Communications link failureThe last packet successfully received from the server was 11 milliseconds ago_caused by: javax.net.ssl.sslexception: received fatal alert: internal_errorhttps://blog.csdn.net/guoheng_123/article/details/132358920

MYSQL关闭SSL的方法分享_mysql关闭ssl连接认证-CSDN博客文章浏览阅读2.4k次,点赞2次,收藏5次。以上为个人经验,希望能给大家一个参考,也希望对你有所帮助。微点阅读。_mysql关闭ssl连接认证https://blog.csdn.net/hdxx2022/article/details/131900725

你可能感兴趣的:(采坑记录,java,mysql)