N
N
nano_e_t_42022-04-07 17:12:23
PostgreSQL
nano_e_t_4, 2022-04-07 17:12:23

How to give all rights to the database?

Hello everyone
, I did grant all privleges on database to user, postgres said it was ok, but when I try to write, permission denied still occurs and I have to manually write grants for tables, schema, sequences, functions.
Please tell me why it does not issue all permissions to the user on grant all privleges on database and how to register all restrictions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mureevms, 2022-04-08
@nano_e_t_4

Here , in fact, the answer to the question why grant all privleges does not do what you expect from it.
In general, if you create the first user for a new database, you should make that user the owner of that database. Executed as superuser:
alter database DB_NAME owner to USER_NAME;
If you want to add a second user with full rights, you will have to iterate over all types of allowed operations for all types of database objects.

N
nsnoob, 2022-04-08
@nsnoob

CREATE USER user_name WITH PASSWORD 'user_password';

ALTER DATABASE db_name OWNER TO user_name;

GRANT ALL PRIVILEGES ON DATABASE db_name TO user_name;

\c db_name

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA PUBLIC TO user_name;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question