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!
Option 2: Edit the MySQL Configuration File Scroll down to the [mysqld] section, and find the default-time-zone = "+00:00" line. Change the +00:00 value to the GMT value for the time zone you want. Save the file and exit. In the example below we set the MySQL Server time zone to +08:00 (GMT +8).
If you've ever had to work with servers, you're probably familiar with UTC time, also known as Coordinated Universal Time. UTC time is the standardized time used by most computers and servers around the world.
To explicitly specify the system time zone for MySQL Server at startup, set the TZ environment variable before you start mysqld. If you start the server using mysqld_safe, its --timezone option provides another way to set the system time zone. The permissible values for TZ and --timezone are system dependent.
@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).
First see your mysql server timezone:mysql -e "SELECT @@global.time_zone;" -u <mysqluser> -p
.
Most probably it should be SYSTEM
.
Find your system timezone: date +”%Z
.
See if its CEST.
You need to change your system timezone:
#cd /usr/share/zoneinfo #ls -l #rm /etc/localtime #ln -s /usr/share/zoneinfo/UTC /etc/localtime
Then restart your mysql server: /etc/init.d/mysqld restart
.
Enjoy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With