doc: Fix description of how the default user name is chosen

This makes the distinction between operating-system user name and
database user name a bit clearer.  It also clarifies that the user
name is determined first, and then the default database name.

Author: David G. Johnston <david.g.johnston@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAKFQuwZUhgz=sUi+wGQV-PBTNjMovuA-BOV88RV-Vw0m0drCAg@mail.gmail.com
This commit is contained in:
Peter Eisentraut 2022-11-24 09:04:50 +01:00
parent af205152ef
commit 385da7306c
2 changed files with 9 additions and 8 deletions

View File

@ -2313,7 +2313,7 @@ FATAL: database "testdb" does not exist
</programlisting>
The database you are trying to connect to does not exist. Note that
if you do not specify a database name, it defaults to the database
user name, which might or might not be the right thing.
user name.
</para>
<tip>

View File

@ -646,23 +646,24 @@ EOF
<application>psql</application> is a regular
<productname>PostgreSQL</productname> client application. In order
to connect to a database you need to know the name of your target
database, the host name and port number of the server, and what user
name you want to connect as. <application>psql</application> can be
told about those parameters via command line options, namely
database, the host name and port number of the server, and what
database user name you want to connect as. <application>psql</application>
can be told about those parameters via command line options, namely
<option>-d</option>, <option>-h</option>, <option>-p</option>, and
<option>-U</option> respectively. If an argument is found that does
not belong to any option it will be interpreted as the database name
(or the user name, if the database name is already given). Not all
(or the database user name, if the database name is already given). Not all
of these options are required; there are useful defaults. If you omit the host
name, <application>psql</application> will connect via a Unix-domain socket
to a server on the local host, or via TCP/IP to <literal>localhost</literal> on
Windows. The default port number is
determined at compile time.
Since the database server uses the same default, you will not have
to specify the port in most cases. The default user name is your
operating-system user name, as is the default database name.
to specify the port in most cases. The default database user name is your
operating-system user name. Once the database user name is determined, it
is used as the default database name.
Note that you cannot
just connect to any database under any user name. Your database
just connect to any database under any database user name. Your database
administrator should have informed you about your access rights.
</para>