在访问共享模式下锁定表public.users_receipthash

时间:2018-08-30 17:50:58

标签: postgresql ubuntu

我正在尝试运行:

pg_dump database_name > database_name_08_27_2018

但出现以下错误:

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

pg_dump: [archiver (db)] query was: LOCK TABLE public.users_receipthash IN ACCESS SHARE MODE

我该如何解决? Ubuntu 16.04服务器

1 个答案:

答案 0 :(得分:0)

让我们假设您有桌子:

t=# create table users_receipthash(); CREATE TABLE

您要么需要成为它的所有者:

t=# \dt users_receipthash
             List of relations
 Schema |       Name        | Type  | Owner
--------+-------------------+-------+-------
 public | users_receipthash | table | vao
(1 row)

或已为您授予所有者角色

t=# grant vao to root;
GRANT ROLE

或成为超级用户:

t=# \du vao
              List of roles
 Role name | Attributes |    Member of
-----------+------------+-----------------
 vao       | Superuser  | {dba, PostgresRules}

如果您不想成为一个人,请以sueruser身份运行

t=# alter user vao superuser;
ALTER ROLE

现在,我使用 you 来指代您用于连接数据库的db用户。您省略了连接字符串上的-U键,因此我假设您对os用户使用对等身份验证。在我的情况下,我使用os用户 vao (和数据库用户 vao