2

I recently created a test database but I would like it to be accessible to all users.

I created the database as user postgres then use the command

GRANT ALL ON DATABASE dbname TO public;

But when I log out and try to connect to it with a different user I get this error

psql -d dbname
psql: FATAL:  role "username" does not exist

I don't want to have to create a user for each person who will be accessing the database which is the reason i wanted to make it public. Is there a permission that I am still missing?

1 Answer 1

4

Although access to everybody (public) is granted, the user you connect with has to exist. The default for psql is the username of your system account. You can, of course, create a passwordless anonymous user everybody can use to connect:

psql -U anonymous dbname
Sign up to request clarification or add additional context in comments.

3 Comments

Or the equivalent psql dbname anonymous, +1
doesn't that defeat the point of granting public access to the database, it's not really public if you have to be a user to connect to it
Public in this context means "every user the DBMS knows about"

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.