0

I'm trying to setup a new project with a Postgresql 15.5 database.

I have a running instance. If I create a new database

psql --command "create database \"tagger-db\""

create a new user

psql --command "create user \"tagger-user\""

grant all privileges on the new database to the new user

psql --command "grant all privileges on database \"tagger-db\" to \"tagger-user\""

if I then try to create a table with the new user

psql -U "tagger-user" -d "tagger-db" --command "create table users (id uuid primary key)"

I get the following error

ERROR:  permission denied for schema public

what is the correct way to grant to the new user all the privileges on the the database?

1 Answer 1

1

ALL PRIVILEGES ON DATABASE means all of these three: CREATE, CONNECT, and TEMPORARY, nothing else. If you want your new user to create objects in the PUBLIC schema (not a good idea), you need to grant privileges on that schema as well.

1
  • 1
    Thanks! You mean I should also run something like psql -d "tagger-db" --command "grant all on schema public to \"tagger-user\"", correct? Commented Apr 10, 2024 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.