首页
/
每日頭條
/
科技
/
mysql 時區查看
mysql 時區查看
更新时间:2025-02-13 18:11:41
概述

今天主要針對mysql時區這方面做一個總結,這裡介紹兩個參數:system_time_zone和time_zone。


01全局參數system_time_zone

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

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.


02全局參數time_zone

用來設置每個連接會話的時區,默認為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”).


03參數log_timestamps

用于設置Error Log/Genaral Log/Slow Log這三種日志的時間信息。

有效值為UTC(默認)和SYSTEM(本地系統時區),當設置為system時,會使用參數system_time_zone的值。


04修改參數time_zone

# 啟動命令 --default-time-zone=timezone # 配置文件 default-time-zone=timezone # 運行期間 set global time_zone=' 8:00';

mysql 時區查看(MySQL時區設置總結--參數system)1

mysql 時區查看(MySQL時區設置總結--參數system)2

查看操作系統時區

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

mysql 時區查看(MySQL時區設置總結--參數system)3

ps:如果無法修改操作系統時區,又希望數據庫使用其他時區,則可以使用參數time_zone來修改。


後面會分享更多devops和DBA方面的内容,感興趣的朋友可以關注一下~

mysql 時區查看(MySQL時區設置總結--參數system)4

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
Copyright 2023-2025 - www.tftnews.com All Rights Reserved