今天在使用IDEA時鏈接數據庫發生錯誤,因此用其自帶的嘗試鏈接獲得以下錯誤:
Connection to test@127.0.0.1 failed.
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.mysql
此方法能夠嘗試在末尾加上時區,一般即可解決。sql
能夠按照須要修改此URL:數據庫
jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai
或者修改此完整的URL:spa
jdbc:mysql://127.0.0.1:3306/test?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&autoReconnect=true