1. 程式人生 > 其它 >041.PGSQL-pgsql時間日期錯誤問題,原來是系統時間問題,我擦

041.PGSQL-pgsql時間日期錯誤問題,原來是系統時間問題,我擦

pgsql時間錯誤問題

mydb@[local]:5432=#select now();
now
-------------------------------
2021-07-05 08:07:22.981157+08


mydb@[local]:5432=# show time zone;
TimeZone
---------------
Asia/Shanghai
(1 row)

檢視可供選擇的時區

mydb@[local]:5432=#select * from pg_timezone_names;
                  name                  
| abbrev | utc_offset | is_dst ----------------------------------------+--------+------------+-------- Africa/Accra | GMT | 00:00:00 | f Africa/Algiers | CET | 01:00:00 | f Africa/Bissau | GMT | 00:00:00 | f Africa/Casablanca |
WEST | 01:00:00 | t Africa/Ceuta | CEST | 02:00:00 | t Africa/El_Aaiun | WEST | 01:00:00 | t Africa/Monrovia | GMT | 00:00:00 | f Africa/Ndjamena | WAT | 01:00:00 | f Africa/Tunis | CET |
01:00:00 | f Africa/Windhoek | WAT | 01:00:00 | f Africa/Abidjan | GMT | 00:00:00 | f Africa/Bamako | GMT | 00:00:00 | f Africa/Banjul | GMT | 00:00:00 | f Africa/Conakry | GMT | 00:00:00 | f

中國公用時間(PRC指:People's Republic of China)

mydb@[local]:5432=#select * from pg_timezone_names where name = 'PRC';
name | abbrev | utc_offset | is_dst
------+--------+------------+--------
PRC | CST | 08:00:00 | f
(1 row)

修改配置檔案

[root@s101 /var/lib/pgsql/13/data]#nano postgresql.conf
log_timezone = 'PRC'

timezone = 'PRC'

重啟資料庫

[root@s101 /var/lib/pgsql/13/data]#sudo systemctl restart postgresql-13

再次檢視還是沒變

原來是系統時間錯誤

設定系統時間

https://blog.csdn.net/weixin_43545225/article/details/106118354

再次檢視