Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

mysql - The server time zone value 'CEST' is unrecognized

I am using hibernate (Hibernate Maven 5.2.15.Final, Mysql-connector Maven 8.0.9-rc) whith mysql 5.7 on lampp environment on linux so.

I am in Italy (Central European Summer Time) and once March 25, occurs follow error on connection db:

The server time zone value 'CEST' 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.

On mysql console, I ran:

SHOW GLOBAL VARIABLES LIKE 'time_zone';
SET GLOBAL time_zone='Europe/Rome'; 

but that did not persist.

Then I added to my.cnf file (in /etc/mysql):

[mysqld] 
default-time-zone = 'Europe/Rome' 

and also:

default_time_zone = 'Europe/Rome' 

but the db server did not start still...

Why does the error occur? Could someone help me?

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

@aiman's answer is not correct since in your case the effective server timezone is not UTC.

You'll find on the net some solutions including additional parameters on the jdbc connection string, but there are cases where you cannot change this string.

Here's how I fixed it:

First import the system timezones in mysql:

$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

Then set your default mysql server timezone in the [mysqld] section of /etc/mysql/my.cnf (or of /etc/mysql/mysql.conf.d/mysqld.cnf on recent Debian/Ubuntu distros) to your actual server timezone, for instance:

default_time_zone = Europe/Paris

and don't forget to restart mysql

$ sudo service mysql restart

(or the appropriate command depending on your distro).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...