1. Introduction

Recently I had an issue with my Spring application that was unable to connect to the database due to "The server time zone value CEST is unrecognized or represents more than one time zone"

There are few solutions to this one - for example, one would be to change our connection string and add a time zone to the end of it:


But, since this requires changes in the connection string it's not always possible to apply this approach.

2. The solution

What worked for me was the following:

1. Import the system time zones into MySql using the following command:

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

2. Add your default MySql server timezone in the [mysqld] section of MySql configuration file that could be found at  /etc/mysql/my.cnf or  /etc/mysql/mysql.conf.d/mysqld.cnf  (with recent Debian/Ubuntu distributions):

default_time_zone = +02:00

3. Restart the MySql service:

$ sudo service mysql restart

3. Conclusion

In this quick tutorial, we showed how to solve an issue with an unrecognized time zone during the connection of Java application to the MySql database.