温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么解决PostgreSQL日期格式导致的错误

发布时间:2021-11-09 15:25:45 来源:亿速云 阅读:164 作者:iii 栏目:关系型数据库

这篇文章主要讲解了“怎么解决PostgreSQL日期格式导致的错误”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么解决PostgreSQL日期格式导致的错误”吧!

由于日期格式的不同,PostgreSQL在执行恢复读取recovery.conf的时候会出现问题.
错误信息
在recovery.conf文件,recovery_target_time的设置

recovery_target_time='2019-3-11 14:40:00'

如按上述设置,则会出现错误

[xdb@localhost testdb]$ pg_ctl start
waiting for server to start....2019-03-11 14:04:45.121 CST [21749] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2019-03-11 14:04:45.121 CST [21749] LOG:  listening on IPv6 address "::", port 5432
2019-03-11 14:04:45.123 CST [21749] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-03-11 14:04:45.135 CST [21749] LOG:  redirecting log output to logging collector process
2019-03-11 14:04:45.135 CST [21749] HINT:  Future log output will appear in directory "log".
 stopped waiting
pg_ctl: could not start server
Examine the log output.

日志提示

[xdb@localhost log]$ cat postgresql-2019-03-11_122129.csv
2019-03-11 12:21:29.233 CST,,,1680,,5c85e249.690,1,,2019-03-11 12:21:29 CST,,0,LOG,00000,"ending log output to stderr",,"Futu
2019-03-11 12:21:29.236 CST,,,1682,,5c85e249.692,1,,2019-03-11 12:21:29 CST,,0,LOG,00000,"database system was interrupted; la
2019-03-11 12:21:29.249 CST,,,1682,,5c85e249.692,2,,2019-03-11 12:21:29 CST,,0,FATAL,42601,"syntax error in file ""recovery.c
2019-03-11 12:21:29.250 CST,,,1680,,5c85e249.690,2,,2019-03-11 12:21:29 CST,,0,LOG,00000,"startup process (PID 1682) exited w
2019-03-11 12:21:29.250 CST,,,1680,,5c85e249.690,3,,2019-03-11 12:21:29 CST,,0,LOG,00000,"aborting startup due to startup pro
2019-03-11 12:21:29.252 CST,,,1680,,5c85e249.690,4,,2019-03-11 12:21:29 CST,,0,LOG,00000,"database system is shut down",,,,,,

在recovery.conf文件的第3行有语法错误,猜测是日期格式问题

日期格式

testdb=# show datestyle;
 DateStyle 
-----------
 ISO, MDY
(1 row)

PG日期格式为月-日-年,recovery.conf文件的日期调整为该格式即可解决上述问题.

感谢各位的阅读,以上就是“怎么解决PostgreSQL日期格式导致的错误”的内容了,经过本文的学习后,相信大家对怎么解决PostgreSQL日期格式导致的错误这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI