Linux mysql 时区设置

环境:centOS 7.9

lsb_release -a
Operating System: CentOS Linux 7 (Core)

1、操作系统时区设置

#Linux中我们可以使用`date -R`查看本地时区
date -R
#或者直接使用date查看的是CST的时区

1.1、timedatectl list-timezones 可以查看所有可以设置的时区

# 列出伦敦 时区设置
timedatectl list-timezones | grep 'London'
Europe/London

1.2、设置时区

timedatectl set-timezone Europe/London

1.3、使用timedatectl命令也可以看到时区已经修改

timedatectl


      Local time: Sun 2023-12-17 05:23:08 GMT
  Universal time: Sun 2023-12-17 05:23:08 UTC
        RTC time: Sun 2023-12-17 05:23:08
       Time zone: Europe/London (GMT, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2023-10-29 01:59:59 BST
                  Sun 2023-10-29 01:00:00 GMT
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2024-03-31 00:59:59 GMT
                  Sun 2024-03-31 02:00:00 BST

2、mysql时区

-- 1、查看系统时区: @@global.system_time_zone
-- 2、查看全局时区 @@global.time_zone
-- 3、查看客户端时区 @@session.time_zone

SELECT @@global.time_zone, @@session.time_zone,@@global.system_time_zone;

如下设置与SYSTEM相关,及系统时间与OS一致

如果需要设置,请参考文档:

MySQL设置时区_mysql时区设置-CSDN博客

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值