![](/img/trans.png)
[英]How to connect to postgresql google cloud sql instance? Need to import postgresql dump using pg_restore command
[英]How do I dump a Google Cloud SQL for PostgreSQL DB to import back into a regular PostgreSQL DB?
我正在嘗試從 Google Cloud SQL (PostgreSQL) 實例導出我的數據,以便使用pg_dump
和pg_restore
將其導入常規 Postgres 數據庫:
pg_dump -h sql_proxy -F t --no-owner --no-acl > backup.tar
pg_restore backup.tar -c
但是,在運行pg_restore
時出現以下錯誤:
pg_restore: [archiver (db)] 處理 TOC 時出錯:pg_restore: [archiver (db)] TOC 條目 197 中的錯誤; 1259 17010 TABLE xxx postgres pg_restore:[archiver (db)] 無法執行查詢:錯誤:角色“postgres”不存在命令是:ALTER TABLE public.xxx OWNER TO postgres;
pg_restore: [archiver (db)] TOC 條目 198 中的錯誤; 1259 17017 TABLE xxy postgres pg_restore:[archiver (db)] 無法執行查詢:錯誤:角色“postgres”不存在命令是:ALTER TABLE public.xxy OWNER TO postgres;
...
我嘗試了一些標志的變體,但沒有運氣。 我發現了許多關於如何以相反的方式遷移(從 PostgreSQL 到 Google Cloud SQL for PostgreSQL)的文章,而Google Cloud 文檔僅描述了如何導出數據以再次導入 Cloud SQL DB。
我將不勝感激有關如何避免上述錯誤以及如何以盡可能少的更改遷移數據庫的任何幫助。
您需要在要導入轉儲的實例中預先創建引用的角色。
有兩種方法可以實現:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.