kagxin / blog

个人博客:技术、随笔、生活
https://github.com/kagxin/blog/issues
7 stars 0 forks source link

postgres 时区修改 #41

Open kagxin opened 4 years ago

kagxin commented 4 years ago

pgsql 时区修改

查看pgsql 支持的时区

select * from pg_timezone_names;
                  name                  | abbrev | utc_offset | is_dst 
----------------------------------------+--------+------------+--------
 MST                                    | MST    | -07:00:00  | f
 Antarctica/Rothera                     | -03    | -03:00:00  | f
 Antarctica/Vostok                      | +06    | 06:00:00   | f
 Antarctica/Macquarie                   | +11    | 11:00:00   | f
 Antarctica/DumontDUrville              | +10    | 10:00:00   | f
 Antarctica/Palmer                      | -03    | -03:00:00  | f
 Antarctica/Syowa                       | +03    | 03:00:00   | f
 Antarctica/South_Pole                  | NZST   | 12:00:00   | f
 Antarctica/McMurdo                     | NZST   | 12:00:00   | f
 Antarctica/Mawson                      | +05    | 05:00:00   | f
 Antarctica/Davis                       | +07    | 07:00:00   | f
 Antarctica/Troll                       | +02    | 02:00:00   | t

查看配置文件位置

show config_file;

修改配置文件中的 log_timezone 和 timezone为需要的时区

log_timezone = 'Asia/Shanghai'
timezone = 'Asia/Shanghai'

重启postgres

查看时区

show time zone;

linux系统时区修改

rm /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime