MySQL時區參數,mysql時區

來源:互聯網
上載者:User

MySQL時區參數,mysql時區

環境介紹:

OS版本:RHEL5.5

MySQL版本:5.5.40

參考連結:http://dev.mysql.com/doc/refman/5.5/en/time-zone-leap-seconds.html

有一個需求:一個考勤系統,多個AP分布在全球,時間必須以+8時區來計算,那必須修改MySQL伺服器時間來決定!


查看mysql server當前時區
mysql> show variables like '%time_zone%';     
+------------------+--------+  
| Variable_name    | Value  |  
+------------------+--------+  
| system_time_zone | CST    |  
| time_zone        | SYSTEM |  
+------------------+--------+  
2 rows in set (0.00 sec)  

修改辦法:
方法1:修改my.cnf
[mysqld]
default-time-zone='+8:00'
儲存,退出
重啟mysql 伺服器


方法2:修改參數
mysql> set time_zone = '+8:00';
驗證:  
mysql> show variables like '%time_zone%';     
+------------------+--------+  
| Variable_name    | Value  |  
+------------------+--------+  
| system_time_zone | CST    |  
| time_zone        | +08:00 |  
+------------------+--------+  
2 rows in set (0.00 sec) 

mysql> select now(); 
+---------------------+
| now()               |
+---------------------+
| 2011-18-21 18:39:07 |
+---------------------+
1 row in set (0.00 sec)

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.