0

I have created a Postgres user user1, and granted all permission to my_db, when I try to select a table from the database, I'm getting a permission denied error.

Create user1

>>zya$ psql -d postgres
psql (9.6.3)
Type "help" for help.
postgres=# CREATE USER user1  WITH PASSWORD 'password1';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE my_db to user1;
GRANT
postgres=# \q

Login as user1

>>zya$ psql -d my_db --username=user1
psql (9.6.3)
Type "help" for help.

    my_db=> SELECT DISTINCT  name FROM user_tbl order by id;
ERROR:  permission denied for relation user_tbl
2
  • 4
    Possible duplicate of Give all the permissions to a user on a DB Commented Jun 22, 2017 at 22:05
  • It's a duplicate, and the solutions in that question will work for the asker. Commented Jun 22, 2017 at 22:11

2 Answers 2

2
ALTER DATABASE name OWNER TO new_owner;

you have to change database my_db owner to your username user1

Sign up to request clarification or add additional context in comments.

Comments

0

I know this might be late but what you might want to do is to assign This is from my trials and I was able to fix similar issue. It seems you have to set similar privileges to tables function and sequences like shown below

    GRANT ALL PRIVILEGES ON DATABASE yourdb TO yourusr;
    GRANT ALL ON ALL TABLES IN SCHEMA your_schema TO yourusr;
    GRANT ALL ON ALL SEQUENCES IN SCHEMA your_schema TO yourusr;
    GRANT ALL ON ALL FUNCTIONS IN SCHEMA your_schema TO yourusr;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.