2 32.15. Environment Variables #
4 The following environment variables can be used to select default
5 connection parameter values, which will be used by PQconnectdb,
6 PQsetdbLogin and PQsetdb if no value is directly specified by the
7 calling code. These are useful to avoid hard-coding database connection
8 information into simple client applications, for example.
9 * PGHOST behaves the same as the host connection parameter.
10 * PGSSLNEGOTIATION behaves the same as the sslnegotiation connection
12 * PGHOSTADDR behaves the same as the hostaddr connection parameter.
13 This can be set instead of or in addition to PGHOST to avoid DNS
15 * PGPORT behaves the same as the port connection parameter.
16 * PGDATABASE behaves the same as the dbname connection parameter.
17 * PGUSER behaves the same as the user connection parameter.
18 * PGPASSWORD behaves the same as the password connection parameter.
19 Use of this environment variable is not recommended for security
20 reasons, as some operating systems allow non-root users to see
21 process environment variables via ps; instead consider using a
22 password file (see Section 32.16).
23 * PGPASSFILE behaves the same as the passfile connection parameter.
24 * PGREQUIREAUTH behaves the same as the require_auth connection
26 * PGCHANNELBINDING behaves the same as the channel_binding connection
28 * PGSERVICE behaves the same as the service connection parameter.
29 * PGSERVICEFILE specifies the name of the per-user connection service
30 file (see Section 32.17). Defaults to ~/.pg_service.conf, or
31 %APPDATA%\postgresql\.pg_service.conf on Microsoft Windows.
32 * PGOPTIONS behaves the same as the options connection parameter.
33 * PGAPPNAME behaves the same as the application_name connection
35 * PGSSLMODE behaves the same as the sslmode connection parameter.
36 * PGREQUIRESSL behaves the same as the requiressl connection
37 parameter. This environment variable is deprecated in favor of the
38 PGSSLMODE variable; setting both variables suppresses the effect of
40 * PGSSLCOMPRESSION behaves the same as the sslcompression connection
42 * PGSSLCERT behaves the same as the sslcert connection parameter.
43 * PGSSLKEY behaves the same as the sslkey connection parameter.
44 * PGSSLCERTMODE behaves the same as the sslcertmode connection
46 * PGSSLROOTCERT behaves the same as the sslrootcert connection
48 * PGSSLCRL behaves the same as the sslcrl connection parameter.
49 * PGSSLCRLDIR behaves the same as the sslcrldir connection parameter.
50 * PGSSLSNI behaves the same as the sslsni connection parameter.
51 * PGREQUIREPEER behaves the same as the requirepeer connection
53 * PGSSLMINPROTOCOLVERSION behaves the same as the
54 ssl_min_protocol_version connection parameter.
55 * PGSSLMAXPROTOCOLVERSION behaves the same as the
56 ssl_max_protocol_version connection parameter.
57 * PGGSSENCMODE behaves the same as the gssencmode connection
59 * PGKRBSRVNAME behaves the same as the krbsrvname connection
61 * PGGSSLIB behaves the same as the gsslib connection parameter.
62 * PGGSSDELEGATION behaves the same as the gssdelegation connection
64 * PGCONNECT_TIMEOUT behaves the same as the connect_timeout
66 * PGCLIENTENCODING behaves the same as the client_encoding connection
68 * PGTARGETSESSIONATTRS behaves the same as the target_session_attrs
70 * PGLOADBALANCEHOSTS behaves the same as the load_balance_hosts
72 * PGMINPROTOCOLVERSION behaves the same as the min_protocol_version
74 * PGMAXPROTOCOLVERSION behaves the same as the max_protocol_version
77 The following environment variables can be used to specify default
78 behavior for each PostgreSQL session. (See also the ALTER ROLE and
79 ALTER DATABASE commands for ways to set default behavior on a per-user
80 or per-database basis.)
81 * PGDATESTYLE sets the default style of date/time representation.
82 (Equivalent to SET datestyle TO ....)
83 * PGTZ sets the default time zone. (Equivalent to SET timezone TO
85 * PGGEQO sets the default mode for the genetic query optimizer.
86 (Equivalent to SET geqo TO ....)
88 Refer to the SQL command SET for information on correct values for
89 these environment variables.
91 The following environment variables determine internal behavior of
92 libpq; they override compiled-in defaults.
93 * PGSYSCONFDIR sets the directory containing the pg_service.conf file
94 and in a future version possibly other system-wide configuration
96 * PGLOCALEDIR sets the directory containing the locale files for