tft每日頭條

 > 科技

 > mysql涉及的時區

mysql涉及的時區

科技 更新时间:2024-10-14 19:07:28
概述

今天主要針對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時區設置看這篇就夠了)1

mysql涉及的時區(想學mysql時區設置看這篇就夠了)2

查看操作系統時區

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

mysql涉及的時區(想學mysql時區設置看這篇就夠了)3

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


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

mysql涉及的時區(想學mysql時區設置看這篇就夠了)4

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved