The example in this article summarizes the method of MySQL modifying time zone. Share to everyone for your reference, specific as follows:
Description: Here is a summary of the three ways to modify the MySQL time zone.
Method One: Dynamic modification via MySQL command line mode
1.1 View MySQL current time, current timezone
> select Curtime (); #或select now () can also be
+-----------+
| curtime () |
+-----------+
| 15:18:10 |
+-----------+
> show variables like "%time_zone%";
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| Time_zone | SYSTEM |
+------------------+--------+
2 rows in Set (0.00 sec)
#time_zone说明mysql使用system的时区, system_time_ Zone Description system uses CST time zone
1.2 Modifying time zones
> Set Global time_zone = ' +8:00 '; # #修改mysql全局时区为北京时间, our East 8
> Set time_zone = ' +8:00 '; # #修改当前会话时区
> Flush privileges; #立即生效
Method Two: Modify the time zone by modifying the MY.CNF configuration file
# vim/etc/my.cnf # #在 the [mysqld] area plus
default-time_zone = ' +8:00 '
#/etc/init.d/mysqld Restart # #重启mysql使新时区生效
Method Three: If not convenient to restart MySQL, but also want to temporarily resolve the time zone problem, you can initialize MySQL in PHP or other languages when initializing MySQL time zone
Here, take PHP for example, use under mysql_connect ():
mysql_query ("SET time_zone = ' +8:00 '")
This allows you to change the time zone without restarting. However, some of the system functions of MySQL are still not available as: Now (). This sentence, still can't understand.
More information about MySQL interested readers can view the site topics: "MySQL Log operation skills Daquan", "MySQL Transaction operation skills Summary", "MySQL stored process skills encyclopedia", "MySQL database lock related skills summary" and "MySQL commonly used function large summary"
I hope this article will help you with the MySQL database meter.