linux时区不对造成数据库时间混乱

select dbtimezone from dual;
 select sessiontimezone from dual;
SELECT TZ_OFFSET(SESSIONTIMEZONE), TZ_OFFSET(DBTIMEZONE) FROM DUAL;

207
20:09:12 SQL> select dbtimezone from dual;
DBTIMEZONE
----------
+00:00

20:34:15 SQL>  select sessiontimezone from dual;
SESSIONTIMEZONE
---------------------------------------------------------------------------
+08:00

20:35:24 SQL> 

208

20:34:01 SQL> select dbtimezone from dual;
DBTIMEZONE
----------
+08:00

20:34:30 SQL>  select sessiontimezone from dual;
SESSIONTIMEZONE
---------------------------------------------------------------------------
+08:00




timedatectl set-timezone 'Asia/Shanghai'

timedatectl set-timezone 'Asia/Shanghai'
timedatectl set-ntp no

 timedatectl set-time 2021-12-19
timedatectl set-time 20:25:38



使用timedatectl可以进行如下常见操作
1.查看当前时间/日期/时区:timedatectl或者timedatectl status
2.查看所有可用时区:timedatectl list-timezones
3.设置时区:timedatectl set-timezone “Asia/Shanghai”   或者  timedatectl set-timezone PRC
4.设置时间:timedatectl set-time HH:MM:SS
5.设置日期:timedatectl set-time YYYY-MM-DD
6.设置日期时间:timedatectl set-time “YYYY-MM-DD HH:MM:SS”
7.设置硬件时钟为本地时间:timedatectl set-local-rtc 1
8.设置硬件时钟为UTC时间:timedatectl set-local-rtc 0
9.启动NTP时间同步(启用NTP服务或者Chrony服务):timedatectl set-ntp true
10.禁用NTP时间同步:timedatectl set-ntp false

LANG=zh_CN.UTF-8
LANG=en_US.UTF-8

shutdown abort
startup 
alter database set time_zone='+0:00';
select dbtimezone from dual;

上一篇:C语言初阶考试


下一篇:rn 动画Animated