While using psql, I want to change the initial database connection.
I had a database named “test” as the initial connection.
When running psql from the command line my prompt would be test=#
After deleting the “test” database, and running psql in command line, I get the following error:
psql: FATAL: database "test" does not exist
I understand what this means, but how do I go about setting the “postgres” database as the default?
Instead of typing psql postgres each time.
You can configure the default behavior of
psql— and in fact any program using thelibpqclient library — through environment variables.In your
~/.bashrcor similar:The PostgreSQL documentation contains a complete list.