3

I have a linux user account, postgresql role, and associated database, all called foo.

from the linux user foo, I ran the command

dropdb foo

Now when I try to run psql from the linux user foo, I get the error...

psql: FATAL:  database "foo" does not exist

So does this mean that when running psql from a linux user account, there must be a database associated with that linux user account?

4

psql assumes that you want to connect to a database, you can either provide one (just after the command) or it will assume you want to connect to a database whose name is the same as your username (or the account name of the process that started psql):

So, you could write:

psql my_db

or

psql -d my_db

or yet

psql --dbname=my_db

... and psql will connect to the (local) database named my_db.

You have more connection options that you can check in the documentation.

If you don't have yet a database created, check createdb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.