服务器时区值"CEST"无法识别 [英] The server time zone value 'CEST' is unrecognized

查看:252
本文介绍了服务器时区值"CEST"无法识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux的lampp环境上使用了mysql 5.7的hibernate(Hibernate Maven 5.2.15.Final,Mysql-connector Maven 8.0.9-rc).

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.

我在意大利(欧洲中部夏令时),一旦3月25日,发生连接db上的以下错误:

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

服务器时区值"CEST"无法识别或代表更多 多于一个时区.您必须配置服务器或JDBC 驱动程序(通过serverTimezone配置属性)使用更多 如果要利用时区支持,请指定特定的时区值.

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.

在mysql控制台上,我运行:

On mysql console, I ran:

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

但是那并没有持续.

然后我将其添加到my.cnf文件(在/etc/mysql中):

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

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

还有:

default_time_zone = 'Europe/Rome' 

但是数据库服务器仍无法启动...

but the db server did not start still...

为什么会发生错误? 有人可以帮我吗?

Why does the error occur? Could someone help me?

谢谢!

推荐答案

@aiman的答案不正确,因为在您的情况下,有效服务器时区为 not UTC.

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

您会在网上找到一些解决方案,包括jdbc连接字符串上的其他参数,但是在某些情况下您无法更改此字符串.

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

这是我修复它的方式:

首先在mysql中导入系统时区:

First import the system timezones in mysql:

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

然后在/etc/mysql/my.cnf(或最近的Debian/Ubuntu发行版上的/etc/mysql/mysql.conf.d/mysqld.cnf)的[mysqld]部分中将默认的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

别忘了重启mysql

and don't forget to restart mysql

$ sudo service mysql restart

(或适当的命令,具体取决于您的发行版).

(or the appropriate command depending on your distro).

这篇关于服务器时区值"CEST"无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆