Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LOCK TABLE public.users_receipthash IN ACCESS SHARE MODE

I'm trying to run:

pg_dump database_name > database_name_08_27_2018

but got these errors:

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

How can I fix this? Ubuntu 16.04 server

like image 858
0512305012 Avatar asked Oct 29 '25 17:10

0512305012


1 Answers

lets assume you have table:

t=# create table users_receipthash(); CREATE TABLE

you either need to be owner of it:

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

or have owner role granted for you

t=# grant vao to root;
GRANT ROLE

or be a superuser:

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

if you not and you want to be one, run as sueruser

t=# alter user vao superuser;
ALTER ROLE

Now I use you referring to the db user you use connecting to database. You ommit -U key on connection string, thus I assume you use peer authentication for your os user. in my case I use os user vao (and db user vao )

like image 100
Vao Tsun Avatar answered Oct 31 '25 07:10

Vao Tsun