Postgresql - 不同所有者的备份还原? [英] Postgresql - backup restore on different owner?

查看:53
本文介绍了Postgresql - 不同所有者的备份还原?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于 this 我什至投票赞成,但不幸的是,我有 text 转储,我无法使用 pg_restore =(

My question is similar to this I even vote up it, but unfortunately in my case I have text dump and I can not restore using pg_restore =(

zcat /home/kes/work/projects/bennet/db/bennet.sql.gz | \
    pg_restore -h 127.0.0.1 -p 5432 -U bennet --no-owner --role=bennet  -d bennet
pg_restore: error: input file appears to be a text format dump. Please use psql.

但是psql没有roleno-owner选项

有没有办法恢复不同所有者的 text 转储?

Is there a way to restore text dump on different owner?

推荐答案

没有.您有两个选择:

  • 手动编辑 SQL 脚本.这既麻烦又容易出错.

  • Manually edit the SQL script. This is cumbersom and error-prone.

使用 psql 将完整转储恢复到一个新的空临时数据库,并使用 --role--no-owner 根据您的需要.

Restore the complete dump to a new, empty scratch database using psql and dump that with --role and --no-owner as you need.

这篇关于Postgresql - 不同所有者的备份还原?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆