今天在使用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