使用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
在Postgresql工具中,只要指定数据库名称,就可以指定连接字符串.
在pg_restore的语法中,dbname与标志一起传递,而不是作为位置参数传递:
$pg_restore --help pg_restore restores a Postgresql database from an archive created by pg_dump. Usage: pg_restore [OPTION]... [FILE] General options: -d,--dbname=NAME connect to database name ...
所以你应该使用:
pg_restore -d 'postgres://userb:somepassword@somehost.com:5432/otherdatabase' dump.dump
原文地址:https://www.jb51.cc/postgresql/192324.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。