[英]How to restore PostgreSQL database
我在 Ubuntu 中使用 PostgreSQL(它是必需的)在一個名為 Tendenci 的 CMS 項目中工作,我不得不從虛擬機遷移到生產服務器。 但是我在遷移數據庫時遇到了問題。
我使用此命令從 VM 中提取數據:
pg_dump -Fc mydb > db.dump
但是當我嘗試使用此命令將數據導入我的服務器時
psql -d mydb --file=db.dump
這個錯誤出現
The input is a PostgreSQL custom-format dump.
Use the pg_restore command-line client to restore this dump to a database.
當我使用pg_restore
命令時,沒有出現錯誤,但數據庫沒有恢復。
pg_restore -C -d mydb db.dump
要移動整個數據庫集群,包括所有用戶等,請使用以下命令:
$ pg_dumpall >all-db.sql
然后在目標服務器上初始化一個新的空數據庫集群,啟動它,然后運行
$ psql -f all-db.sql
以 postgres 用戶身份運行 pg_dumpall 和 psql 命令。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.