From: Matthias Apitz <guru@unixarea.de>
To: pgsql-general@lists.postgresql.org
Subject: psql's default database on connect (our internal ref. SRP-30861)
Date: Fri, 6 Aug 2021 08:53:22 +0200
Message-ID: <YQzcYh1tAdp72LIZ@c720-r368166> (raw)
Hello,
testpos@srap53dxr1:~> psql --help
...
-d, --dbname=DBNAME database name to connect to (default: "testpos")
testpos@srap53dxr1:~> whoami
testpos
testpos@srap53dxr1:~> env | grep PG
PGPASSWORD=xxxxxxxx
PGHOST=localhost
PGPORT=5432
testpos@srap53dxr1:~> LANG=C psql -Usisis
psql (13.3)
Type "help" for help.
sisis=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 |
sisis | sisis | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 |
...
Why psql connects to the database 'sisis'? I was expecting that it
will try to connect to a database 'testpos' as this is the UNIX login
and as '-d....' was not specified. I was expecting in this case an
error like this:
testpos@srap53dxr1:~> export PGDATABASE=testpos
testpos@srap53dxr1:~> psql -Usisis
psql: error: FATAL: database »testpos« does not exist
What do I uderstand wrong?
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
Tear it down! Defund the Humboldt Forum!
https://www.jungewelt.de/artikel/406715.humboldt-forum-feudaler-themenpark.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: guru@unixarea.de
Subject: Re: psql's default database on connect (our internal ref. SRP-30861)
In-Reply-To: <YQzcYh1tAdp72LIZ@c720-r368166>
References: <YQzcYh1tAdp72LIZ@c720-r368166>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox