簡體   English   中英

pg_restore:錯誤:選項 -d/--dbname 和 -f/--file 不能一起使用

[英]pg_restore: error: options -d/--dbname and -f/--file cannot be used together

我對 postgres 有點陌生,並且在使用pg_restore恢復帶有備份數據的本地數據庫時遇到了麻煩,希望能得到一些幫助。 我的情況如下:

  • 我在 Docker 上運行了 postgres,我可以訪問 pgadmin。
  • 我在 pgadmin 中創建了一個名為 'flocal' 的新服務器,主機名postgres_db用戶名postgres和端口5432
  • 在這個新服務器中,我創建了一個名為fdb的新數據庫
  • 我在本地 PC 上有一個名為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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM