关于IDEA连接MySQL数据库失败的解决方法(报错08001)
2019-05-29 本文已影响0人
于无声处写写写
在IDEA自带的数据库连接工具中,可以连接MySQL数据库,但是有的时候连接出现08001错误,连接不上数据库。
1、一般配置如下所示

Database处填写数据库名字;User处填写mysql设置好的用户名;密码同理填写设置好的;URL部分是在将上述字段填写好以后自动生成的。
2、然后点击Test Connection按钮测试连接


报错信息如上所示
解决办法
将上述的URL改成如下所示
jdbc:mysql://localhost:3306/webuser?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true

再次点击Test Connection按钮,发现可以正确连接上数据库啦

分析
其实在填写URL的时候,我们手动设置了本次连接的一些字段属性,包括useSSL、serverTimeZone、characterEncoding、autoReconnect。这四个属性值。
这些字段属性可以在URL中动态设定,也可以在IDEA中进行全局设置


在上述设置页面中把出现的字段属性值按照指定的设置好即可。