【发布时间】:2015-04-04 04:07:14
【问题描述】:
使用pg_dump时,可以使用postgres连接字符串来指定主机/数据库/用户名/密码:
pg_dump postgres://someuser:somepassword@somehost.com:5432/somedatabase
我想为 pg_restore 使用相同类型的连接字符串:
pg_restore -f dump.dump postgres://userb:somepassword@somehost.com:5432/otherdatabase
但我得到一个错误:
pg_restore: [archiver] could not open input file "postgres://userb:somepassword@somehost.com:5432/otherdatabase": No such file or directory
【问题讨论】:
-
manual is clear 关于你应该使用的标志。
-
手册说:pg_restore [connection-option...] [option...] [filename] 当我尝试:pg-restore postgres://userb:somepassword@somehost.com:5432 /otherdatabase -f dump.dump 我得到同样的错误
-
为什么你认为 [connection-options] 可以接受完整的连接 url?这不是手册所说的。
-
它接受 pg_dump 的完整连接 url - 即使 pg_dump 的手册没有提到能够使用完整连接 url
-
我明白了,但如果我做对了,
pg_dump接受它作为它的dbname参数。那就是带有pg_restore的-d选项。没有选项的参数用作输入filename(带有pg_restore),这是肯定的。