java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more

created at 12-16-2021 views: 8

Problem Description

Today, using Spring-boot to configure MySQL, the startup project throws the following error:

java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.

problem causes

  • The time zone setting is incorrect when installing mysql. MySQL defaults to the time zone of the United States. For example, mainland China is 8 hours later than them, using the format +8:00
  • The database used is MySQL. In the case of SpringBoot2.1, if you do not specify the MySQL driver version, the driver that it automatically relies on is the very high version of 8.0.12, which is caused by the time zone difference between the database and the system. The problem can be solved by adding serverTimezone=GMT to the url of the jdbc connection. If you need to use the gmt+8 time zone, you need to write it as GMT%2B8, otherwise it will be parsed as empty.
  • Another solution is to use a lower version of the MySQL jdbc driver, 5.1.28 will not have a time zone problem.

solution

Add serverTimezone=GMT%2B8 after the configuration database URL

url: jdbc:mysql://127.0.0.1:3306/lucykmoney?serverTimezone=GMT%2B8

Note: Don’t ignore ?

created at:12-16-2021
edited at: 12-16-2021: