If your time zone setting is +08:00 means Beijing time, but our online servers are all UTC time, this difference will bring some unexpected results. Let's set the UTC time zone together!

MySQL root@(none):(none)> show variables like'%time_zone';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | CST    |
| time_zone        | +08:00 |
+------------------+--------+
2 rows in set
Time: 0.025s

step one:

Edit the /etc/my.cnf file

cd /etc
sudo vim my.cnf

Step two:

Enter the following

[mysqld]
default-time-zone='+08:00'  

Save and exit

Step three:

Restart mysql server

Step 4:

Log in to mysql server , if it is the following, it will take effect

MySQL root@(none):(none)> show variables like'%time_zone';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | CST    |
| time_zone        | +00:00 |
+------------------+--------+
2 rows in set
Time: 0.025s

universe_king
3.4k 声望678 粉丝