Home>Article>Database> Solve Mysql time zone error problem in one article

Solve Mysql time zone error problem in one article

WBOY
WBOY forward
2022-08-25 11:40:11 2926browse

Recommended learning:mysql video tutorial

I encountered a problem about mysql time zone while working on the project today, here I will summarize and record the solution process, hoping to help those in need.

Problem Description

I suddenly encountered the following error while working on the project. It can be seen that the time zone of the database is wrong. The Mysql 8.0.15 database is used here.

Here I tried the database visualization plug-in provided by idea.

The following error message makes it impossible to access the database.

org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: 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. ### The error may exist in StudentMapper.xml ### The error may involve ll.getAll ### The error occurred while executing a query ### Cause: 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.

Cause analysis

The first consideration here is the default time zone setting of the database itself.

The second consideration is the time zone setting when setting up the idea database visualization plug-in connection.

Solution:

Solve this problem by following the steps:

Open the command window and enter the mysql service:

Then query the time zone:

show variables like "%time_zone%";

The SYSTEM shown here means following the system. Generally there is no problem, but occasionally there will be problems. Here we will change it directly to ' 8:00'

set global time_zone='+08:00';

Note: This is only a temporary modification, it will become invalid after restarting the mysql service

The permanent modification is introduced below:
Permanent Modification: Modify the mysql configuration file my.ini, add: default-time-zone=' 08:00', restart mysql to take effect, be sure to add it under [mysqld], otherwise unknown variable 'default-time will appear -zone= 8:00'

Next, go to the idea and test it.

It is found that the result is still an error, so it is considered to be a link configuration problem of the idea database visualization plug-in.

Next modify the idea database visualization plug-in configuration:

# #Add time zone '8:00' here to test. Perfect solution.

Recommended learning:

mysql video tutorial

The above is the detailed content of Solve Mysql time zone error problem in one article. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete