今天在使用IDEA时连接数据库发生错误,所以用其自带的尝试连接得到如下错误:
Connection to test@127.0.0.1 failed.
[08001] Could not create
connection to database server. Attempted reconnect 3 times. Giving up.
此方法可以尝试在末尾加上时区,通常便可解决。
可以按照需要修改此URL:
jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai
或者修改此完整的URL:
jdbc:mysql://127.0.0.1:3306/test?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&autoReconnect=true