首先須要查看mysql的當前時區,用time_zone參數mysql
mysql> show variables like '%time_zone%'; +------------------+--------+ | Variable_name | Value | +------------------+--------+ | system_time_zone | CST | | time_zone | SYSTEM | +------------------+--------+
第一步sql
mysql> set global time_zone = '+08:00'; set time_zone = '+08:00';
mysql> flush privileges;服務器
Query OK, 0 rows affected (0.00 sec)
第二部spa
修改的/etc/my.cnf的rest
default-time-zone = '+08:00'code
第三部,重啓mysql服務器,不重啓是不會生效的.blog
[root@iZbp15d0fgh0v1wwql5r4uZ etc]# init.d/mysql restart
修改爲功後是:string
mysql> show variables like '%time_zone%'; +------------------+--------+ | Variable_name | Value | +------------------+--------+ | system_time_zone | CST | | time_zone | +08:00 | +------------------+--------+
第二部很重要,否則怎麼都設置無效it