MySQL Config--參數system_time_zone和參數time_zone

全局參數system_time_zone
系統時區,在MySQL啓動時會檢查當前系統的時區並根據系統時區設置全局參數system_time_zone的值。html

The system time zone. When the server starts, it attempts to determine the time zone of the host machine automatically and uses it to set thesystem_time_zone system variable. The value does not change thereafter.mysql

 

全局參數time_zonesql

用來設置每一個鏈接會話的時區,默認爲system時,使用全局參數system_time_zone的值。數據庫

The current time zone. This variable is used to initialize the time zone for each client that connects. By default, the initial value of this is 'SYSTEM' (which means, 「use the value of system_time_zone」).this

 

參數log_timestamps
用於設置Error Log/Genaral Log/Slow Log這三種日誌的時間信息。
有效值爲UTC(默認)和SYSTEM(本地系統時區),當設置爲system時,會使用參數system_time_zone的值。spa

 

修改參數time_zone操作系統

# 啓動命令 --default-time-zone=timezone # 配置文件 default-time-zone=timezone # 運行期間 set global time_zone = timezone set global time_zone='+8:00' set global time_zone='Asia/Shanghai'

 

查看操做系統時區日誌

## 使用date命令 date +"%Z %z" date -R ## 使用timedatectl timedatectl|grep "Timezone" ## 查看文件 /etc/timezone cat /etc/timezone

 

若是沒法修改操做系統時區,又但願數據庫使用其餘時區,則能夠使用參數time_zone來修改。code

相關文章
相關標籤/搜索