When using JDBC connection MySql given: You must configure either the server or JDBC driver (via the serverTimezone config

在使用JDBC连接MySql时报错: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.

Specific given as follows:

Failed to obtain JDBC Connection; nested exception is 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.

I said here about why there is such a problem, because I created is springboot project, add mysql rely in pom, and did not set the version number, because the internal springboot configured before. The version number is 8.0.13 configuration it is because mysql version is too high, thus giving rise to this error.

If you load mysql version is relatively low, there will not be the case.

Solution:
behind the connection string in the configuration file plus serverTimezone = UTC?

UTC is a unified world standard time

 Complete connection string example: jdbc: mysql: // localhost: 3306 / hello serverTimezone = UTC?

If you specify gmt + 8 time zone, you need to write GMT% 2B8, or it may report an error parsing empty

 

Incidentally, if the input Chinese distortion present, can be set as follows:

jdbc:mysql://127.0.0.1:3306/hello?useUnicode=true&characterEncoding=UTF-8

Of course, in order to secure, you can write the following:

jdbc:mysql://127.0.0.1:3306/hello?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

Published 25 original articles · won praise 6 · views 7540

Guess you like

Origin blog.csdn.net/B_G_boy/article/details/104697999