Issue
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.
Solution
You can configure the default behavior of psql
-- and in fact any program using the libpq
client library -- through environment variables.
In your ~/.bashrc
or similar:
export PGDATABASE=postgres
The PostgreSQL documentation contains a complete list.
Answered By - willglynn Answer Checked By - Robin (WPSolving Admin)