postgresql pg_dump: [archiver (db)] 查询失败:错误:关系 abouts 的权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39329228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:23:12  来源:igfitidea点击:

pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts

rubypostgresqlruby-on-rails-3

提问by Jai Kumar Rajput

I'm trying to dump my pg db but got these errors please suggest

我正在尝试转储我的 pg db 但遇到这些错误请提出建议

pg_dump: [archiver (db)] query failed: ERROR:  permission denied for relation abouts
pg_dump: [archiver (db)] query was: LOCK TABLE public.abouts IN ACCESS SHARE MODE

回答by d1ll1nger

The user which you're performing your pg_dumpas doesn't have permissions on the public schema.

您正在执行的用户pg_dump对公共架构没有权限。

Add permissions if allowed:

如果允许,添加权限:

GRANT USAGE ON SCHEMA public TO <user>;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <user>;

回答by Vinnix

This can be a common error, when using a ROLE(user) that could not open the objects to dump them.

当使用ROLE无法打开对象的(用户)转储对象时,这可能是一个常见错误。

Like said before, you can grant to the specific schema that you want to dump, or even use a ROLEwith SUPERUSERattribute.

如前所述,您可以授予要转储的特定架构,甚至可以使用ROLEwithSUPERUSER属性。

Note that when you are dealing with some cloud database providers, like AWS/RDS you will not receive a user with the SUPERUSERattribute, so you will need to manage to make sure that the one used to dump will have all access needed.

请注意,当您与某些云数据库提供商(如 AWS/RDS)打交道时,您不会收到具有该SUPERUSER属性的用户,因此您需要设法确保用于转储的用户拥有所需的所有访问权限。

https://www.postgresql.org/docs/current/static/sql-grant.htmlwill show how give GRANTto many objects on your database, but also remember that when restoring you will need to create the database first. Only if you are using pg_dumpallthat is not necessary, but you also need to dump the ROLES.

https://www.postgresql.org/docs/current/static/sql-grant.html将显示如何GRANT分配数据库中的许多对象,但请记住,在恢复时您需要先创建数据库。仅当您使用pg_dumpall它时没有必要,但您还需要转储ROLES.