Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql error: The server time zone value is unrecognized or represents more than one time zone

Shulou Source: shulou.com Published: 2022-06-01 18:39:05 10月03日 Update

When programmatically accessing the Mysql database, the time zone error is reported as follows:

The server time zone value 'boys' is unrecognized or represents more than one time zone

There are usually two solutions:

First, add? serverTimezone=UTC, the default 0 time zone, after the database connection statement, but note that the statement needs to be followed in the first position of the database connection statement, otherwise an error will be reported, for example:

Jdbc.url=jdbc:mysql://localhost:3306/testdatabase?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8

However, there is a problem that when the time field is inserted into the database, the time is 8 hours earlier than the current time, that is, the current system time minus 8 hours.

Second, change the time zone of Mysql to East Zone 8, and execute the following command:

Set global time_zone='+8:00'

Tags: Data database time time zone statement hour error location command field method system problem report programming Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux Redmi Shulou Tech Info macOS