Goland 链接数据库失败 以为是Goland IDE的问题,今天IDEA也出现相同问题。
关键还是——“没有合适的协议”(No appropriate protocol
)
[08S01] Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the
server.javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate).
其实官方issue Can't connect to remote MySQL since last version of IntelliJ中已经给出了解决方案——
MySql版本为8.0, 5.7.28, 5.6.46和以上版本,如果服务端启用了TLSv1.2
配置,而客户端没进行对应配置时,就会出现上述问题。
可以在数据库的链接属性data source properties
的高级设置中设置enabledTLSprotocols
的值为TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
(默认这个链接值为空)
If you are running MySQL 8.0, 5.7.28, 5.6.46 and later and your server is configured with TLSv1.2 you can enabled it in driver:
open up data source properties, switch to Advanced tab and set value for enabledTLSprotocols to TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
亲测有效——
另外一个解决方法思路相同,只不过是通过配置文件的方式进行配置——
Workaround #1
We've updated java recently and we've moved to TLSv1
to the jdk.tls.disabledAlgorithms
due to security reasons. So to get it back you need to do the following:
- Create a file
custom.java.security
with the following contents:
jdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
include jdk.disabled.namedCurves
I removed TLSv1
from the list.
-
Go to you data source Advanced tab and add to VM Options:
-Djava.security.properties=${PATH_TO_FILE?}/custom.java.security
. Don't forget to replace${PATH_TO_FILE?}
. -
You can connect.
网友评论