简体   繁体   English

pg_dumpall而不删除超级用户

[英]pg_dumpall without dropping the superuser

I have a postgres 9.6. 我有一个postgres 9.6。 I am using pg_dumpall with -c --if-exists options. 我正在将pg_dumpall-c --if-exists选项一起使用。

When I restore from this backup file as the superuser I am getting errors current user cannot be dropped when it tries to drop the role. 当我以超级用户身份从此备份文件还原时,出现错误,尝试删除角色时current user cannot be dropped And after that I am getting role "mysuperuser" already exists when it tries to create the superuser role. 之后,当我尝试创建超级用户角色时, role "mysuperuser" already exists

These two errors does not effect the success of the restore. 这两个错误不会影响还原成功。 However, I do not want to get irrelevant errors like these. 但是,我不想得到像这样不相关的错误。

What I can do is to remove the two lines which are dropping and creating the aforementioned superuser role. 我可以做的是删除删除的两行,并创建上述的超级用户角色。

Is there a better way to do this? 有一个更好的方法吗? Because in order to achieve that I need to open a huge file and edit it. 因为要实现这一点,我需要打开一个大文件并对其进行编辑。

You might want to join one of the postgreql.org mailing list and see if this irritation has occurred for others. 您可能想加入postgreql.org邮件列表之一,看看是否对其他人产生了这种刺激。 It's clearly not the ideal behaviour. 显然这不是理想的行为。

There is a simple work-around though. 不过,有一个简单的解决方法。 Create a new superuser (that doesn't exist in the backup) and use that user to do the restore. 创建一个新的超级用户(备份中不存在),然后使用该用户进行还原。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM