Answer the question
In order to leave comments, you need to log in
Why are the user rights not granted to work with the database?
Hello, why is it impossible to grant rights to the user, although this method has always worked in my case before.
CREATE DATABASE bot;
CREATE USER botuser WITH PASSWORD 'botpassword';
GRANT ALL PRIVILEGES ON DATABASE bot TO botuser;
\c bot
CREATE TABLE example (id int PRIMARY KEY, name text)
#Дальше через пользователя postgres, делаю коннект к базе командой:
psql -d bot -U botuser
SELECT * FROM example;
#Выходит ошибка: нет доступа к таблице example
#Но если даю права именно на SELECT то получается под пользователем забирать данные:
GRANT SELECT ON ALL TABLES IN SCHEMA public TO botuser;
Answer the question
In order to leave comments, you need to log in
In postgres, permissions are granted to a specific type of object (database, schema, table, sequence, etc.) and depend on this type. In this case, the granted rights to the parent object do not mean the presence of any rights to the child objects.
You gave the user all rights to DATABASE, which means that he can connect to it and create schemas, publications and temporary tables in it. Everything.
You create the example table under a different user, botuser has no rights to it.
https://postgrespro.ru/docs/postgresql/13/ddl-priv
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question