IDEA连接数据库失败@localhost failed. [08001] Could not create connection to database server. Attempte

时间:2024-03-21 15:24:26

关于IDEA连接mysql数据库失败:
Connection to [email protected] failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

IDEA连接数据库失败@localhost failed. [08001] Could not create connection to database server. Attempte

解决办法:在URL后面加上?serverTimezone=UTC

IDEA连接数据库失败@localhost failed. [08001] Could not create connection to database server. Attempte

连接成功!

根本原因是因为时区设置的问题。
UTC代表的是全球标准时间 ,但是我们使用的时间是北京时区也就是东八区,比实际时间要早8小时。

UTC + (+0800) = 本地(北京)时间