How to solve the problem of “08001” when JDBC connects to MySQL

Connection to MySQL – @localhost failed.

[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

is because the connection string of MySQL needs to configure the ServerTimezone attribute, which can be used in UTC, Hongkong, Asiz/Shanghai, etc.

if you use UTC, there will be a time difference of 8 hours, so Hongkong or Asiz/Shanghai is recommended.

for example:

jdbc:mysql://localhost:3306/?serverTimezone=Asia/Shanghai

jdbc:mysql://localhost:3306/MyDB?serverTimezone=Asia/Shanghai


Read More: