0

using postgresql 9.4 on ubuntu 15.04.

logged in as postrges

created following roles: fooadmin, fooread, fooupdate with appropriate privileges for the role.

created following user: fooadminuser

granted role to user: grant fooadmin to fooadminuser;

log out of psql

attempt to login to psql using the following:

psql -U fooadminuser -h localhost -W

get prompted for password/enter password

receive following error message:

psql: FATAL: database "fooadminuser" does not exist

I thought I was doing this correctly by creating the roles, then creating the login users, then login with the user that has the createdb role and create the database.

Is there a way to override during login the attempt to access a non-existent database?

1
  • You should add tag postgresql to Your question. Commented Aug 4, 2015 at 21:24

1 Answer 1

2

You have to connect to an existing database. If You don't provide it, the default is the same as the user. After installation there should be one database named 'postgres'. Try this command:

psql -U fooadminuser -h localhost -d postgres -W
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Michas that worked. Very counter-intuitive to require an admin level user to have to "use" a DB during the connection process, since the user is going to be the owner of the "groups" database which hasn't been created yet.
"Hasn't been create yet" is the issue.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.