idea连接MySQL数据库报错:[08001] Could not create connection to database server. Attempted reconnect 3 times

一、问题描述

今天在使用idea连接mysql数据库的时候出现了如下问题

第一个问题:[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

第二个问题:com.mysql.cj.exceptions.WrongArgumentException: No timezone mapping entry for ‘HongKong’.

经查看MySQL数据库控制台没有问题,但连接过程中总是报下面的错误:

idea连接MySQL数据库报错:[08001] Could not create connection to database server. Attempted reconnect 3 times

二、问题原因

通过分析:

第一个问题【08001】:是数据库驱动包的版本和当前本机数据库的版本不兼容(数据库驱动包版本为8.0版本,而本机数据库的版本为5.6)

第二个问题:serverTimezon配置的问题

三、解决方法

第一个问题:修改MySQL驱动的版本,下载5.X的驱动版本 !!!

可以在Driver:MySQL中更改相应的驱动版本,需要联网下载

idea连接MySQL数据库报错:[08001] Could not create connection to database server. Attempted reconnect 3 times

第二个问题:找到Advanced —> serverTimezone,将value值设置为Asia/Shanghai,然后点击Apply

idea连接MySQL数据库报错:[08001] Could not create connection to database server. Attempted reconnect 3 times

设置完成之后,重新测试连接!!

idea连接MySQL数据库报错:[08001] Could not create connection to database server. Attempted reconnect 3 times