On one server, when I run:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2009-05-30 16:54:29 |
+---------
In my case, the solution was to set serverTimezone parameter in Advanced settings to an appropriate value (CET for my time zone).
As I use IntelliJ, I use its Database module. While adding a new connection to the database and after adding all relevant parameters in tab General, there was an error on "Test Connection" button. Again, the solution is to set serverTimezone parameter in tab Advanced.
For anyone still having this issue:
value="jdbc:mysql://localhost:3306/dbname?serverTimezone=UTC"
Worked for me. Just append ?serverTimezone=UTC
at the end.
This work for me for a location in India:
SET GLOBAL time_zone = "Asia/Calcutta";
SET time_zone = "+05:30";
SET @@session.time_zone = "+05:30";
If you're using PDO:
$offset="+10:00";
$db->exec("SET time_zone='".$offset."';");
If you're using MySQLi:
$db->MySQLi->query("SET time_zone='".$offset."';");
More about formatting the offset here: https://www.sitepoint.com/synchronize-php-mysql-timezone-configuration/
Simply run this on your MySQL server:
SET GLOBAL time_zone = '+8:00';
Where +8:00 will be your time zone.
This is a 10 years old question, but anyway here's what worked for me. I'm using MySQL 8.0 with Hibernate 5 and SpringBoot 4.
I've tried the above accepted answer but didn't work for me, what worked for me is this:
db.url=jdbc:mysql://localhost:3306/testdb?useSSL=false&serverTimezone=Europe/Warsaw
If this helps you don't forget to upvote it :D