Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBtjY-0001UC-Rx for pgsql-general@arkaria.postgresql.org; Fri, 06 Aug 2021 06:53:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mBtjV-0004ia-7J for pgsql-general@arkaria.postgresql.org; Fri, 06 Aug 2021 06:53:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBtjU-0004iR-Uh for pgsql-general@lists.postgresql.org; Fri, 06 Aug 2021 06:53:28 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBtjS-0001d3-Dm for pgsql-general@lists.postgresql.org; Fri, 06 Aug 2021 06:53:27 +0000 Received: from [188.174.48.136] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBtjP-00064e-AA; Fri, 06 Aug 2021 08:53:23 +0200 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.16.1/8.14.9) with ESMTPS id 1766rMMq001614 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 6 Aug 2021 08:53:22 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.16.1/8.14.9/Submit) id 1766rMFs001613; Fri, 6 Aug 2021 08:53:22 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Fri, 6 Aug 2021 08:53:22 +0200 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: psql's default database on connect (our internal ref. SRP-30861) Message-ID: Reply-To: Matthias Apitz MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Operating-System: FreeBSD 13.0-CURRENT r368166 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.48.136 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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