最近我收到很多私信,询问关于他们DataGrip
或其他JetBrains
家IDE的MySQL数据库配置中报错的问题。具体的报错信息大概是这样的:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
The following required algorithms might be disabled: SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves. Edit the list of disabled algorithms to include required algorithms. You can try to enable TLSv1 or TLSv1.1 first.
JDBC driver may have disabled TLS 1.1 and its earlier versions.
其实问我这个问题,无非是想问问是不是本站的插件导致此类问题。但很遗憾,不是!
这个问题我在IDE更新至2021.2
配置数据库时也曾遇到过,当时随手给解决了,以为这个问题并不需要记录。不过从我收到的私信数量来看,事情很明显不是这个样子的。
故而我做了个决定(并不违背祖宗):把我解决问题的办法记录下来,以供大家参考。
方法一
- 建立一个文件(我放在
~/.custom.java.security
,记住这个路径),内容如下:jdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves
- 在IDE配置数据源时,点击
Advanced
选项卡,在VM options:
中输入(其中=
后填写上面那个绝对路径):"-Djava.security.properties=${HOME}/.custom.java.security"
- 点
OK
按钮,现在就可以愉快的操作数据库了。
方法二
-
在IDE配置数据源时,点击
Advanced
选项卡,在VM options:
中输入(其实基本就是方法一
的文件内容):"-Djdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves"
-
点
OK
按钮,现在就可以愉快的操作数据库了。
方法三
- 配置全局的
java.security.properties
,内容也就是上面那些。不过,此法侵入性太高,不够灵活。这里不详细介绍,感兴趣自己去试试。