[英]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.