[英]Why does pg_restore return “options -d/--dbname and -f/--file cannot be used together”?
[英]pg_restore: error: options -d/--dbname and -f/--file cannot be used together
我对 postgres 有点陌生,并且在使用pg_restore
恢复带有备份数据的本地数据库时遇到了麻烦,希望能得到一些帮助。 我的情况如下:
postgres_db
用户名postgres
和端口5432
。fdb
的新数据库fprod
的备份文件夹(如果重要,则为 mac),其中包含一堆.dat.gz
文件。现在我导航到这个备份文件夹并在我的本地终端中运行这个:
pg_restore -h postgres_db -p 5432 -U postgres -d fdb -f fprod
我在下面收到以下错误消息。 我尝试将我的主机名更改为-h localhost
但没有区别。
pg_restore: error: options -d/--dbname and -f/--file cannot be used together
我错过了什么,做错了什么? 请指教。
如手册中所述, -f
没有指定输入文件,它指定了一个输出文件,例如用于--list
命令。
所以你需要:
pg_restore -h postgres_db -p 5432 -U postgres -d fdb fprod
pg_restore
可以恢复到数据库( -d
)或文件( -f
)。
如果您恢复到文件,您需要做的最低限度是:
pg_restore -f some_file.sql the_dump_file.out
这将创建自定义格式转储文件的纯文本版本。
如果您转储到数据库,那么最小值是:
pg_restore -h some_host -d the_database -U a_user the_dump_file.out
您需要包含主机( -h
)/数据库( -d
)/用户( -U
)组合,以便pg_restore
知道如何连接到适当的数据库。 主机是服务器正在侦听的地址(套接字/IP)。 这就是您需要更改为-h localhost
的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.