What to do when psql database does not exist?
: 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?
In case of psql database does not exist -
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 a database created yet, check createdb.