Mini Kabibi Habibi
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Environment Variables</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.2.4 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="libpq - C Library"
HREF="libpq.html"><LINK
REL="PREVIOUS"
TITLE="Event System"
HREF="libpq-events.html"><LINK
REL="NEXT"
TITLE="The Password File"
HREF="libpq-pgpass.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2013-04-01T18:31:22"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.2.4 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="Event System"
HREF="libpq-events.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="libpq.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 31. <SPAN
CLASS="APPLICATION"
>libpq</SPAN
> - C Library</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="The Password File"
HREF="libpq-pgpass.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="LIBPQ-ENVARS"
>31.14. Environment Variables</A
></H1
><P
> The following environment variables can be used to select default
connection parameter values, which will be used by
<CODE
CLASS="FUNCTION"
>PQconnectdb</CODE
>, <CODE
CLASS="FUNCTION"
>PQsetdbLogin</CODE
> and
<CODE
CLASS="FUNCTION"
>PQsetdb</CODE
> if no value is directly specified by the calling
code. These are useful to avoid hard-coding database connection
information into simple client applications, for example.
<P
></P
></P><UL
><LI
><P
>
<TT
CLASS="ENVAR"
>PGHOST</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-HOST"
>host</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGHOSTADDR</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-HOSTADDR"
>hostaddr</A
> connection parameter.
This can be set instead of or in addition to <TT
CLASS="ENVAR"
>PGHOST</TT
>
to avoid DNS lookup overhead.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGPORT</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-PORT"
>port</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGDATABASE</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-DBNAME"
>dbname</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGUSER</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-USER"
>user</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGPASSWORD</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-PASSWORD"
>password</A
> connection parameter.
Use of this environment variable
is not recommended for security reasons, as some operating systems
allow non-root users to see process environment variables via
<SPAN
CLASS="APPLICATION"
>ps</SPAN
>; instead consider using the
<TT
CLASS="FILENAME"
>~/.pgpass</TT
> file (see <A
HREF="libpq-pgpass.html"
>Section 31.15</A
>).
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGPASSFILE</TT
> specifies the name of the password file to
use for lookups. If not set, it defaults to <TT
CLASS="FILENAME"
>~/.pgpass</TT
>
(see <A
HREF="libpq-pgpass.html"
>Section 31.15</A
>).
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSERVICE</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SERVICE"
>service</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSERVICEFILE</TT
> specifies the name of the per-user
connection service file. If not set, it defaults
to <TT
CLASS="FILENAME"
>~/.pg_service.conf</TT
>
(see <A
HREF="libpq-pgservice.html"
>Section 31.16</A
>).
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGREALM</TT
> sets the Kerberos realm to use with
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>, if it is different from the
local realm. If <TT
CLASS="ENVAR"
>PGREALM</TT
> is set,
<SPAN
CLASS="APPLICATION"
>libpq</SPAN
> applications will attempt
authentication with servers for this realm and use separate ticket
files to avoid conflicts with local ticket files. This
environment variable is only used if Kerberos authentication is
selected by the server.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGOPTIONS</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-OPTIONS"
>options</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGAPPNAME</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-APPLICATION-NAME"
>application_name</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSSLMODE</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SSLMODE"
>sslmode</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGREQUIRESSL</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-REQUIRESSL"
>requiressl</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSSLCOMPRESSION</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SSLCOMPRESSION"
>sslcompression</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSSLCERT</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SSLCERT"
>sslcert</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSSLKEY</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SSLKEY"
>sslkey</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSSLROOTCERT</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT"
>sslrootcert</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSSLCRL</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-SSLCRL"
>sslcrl</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGREQUIREPEER</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-REQUIREPEER"
>requirepeer</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGKRBSRVNAME</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME"
>krbsrvname</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGGSSLIB</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-GSSLIB"
>gsslib</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGCONNECT_TIMEOUT</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-CONNECT-TIMEOUT"
>connect_timeout</A
> connection parameter.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGCLIENTENCODING</TT
> behaves the same as the <A
HREF="libpq-connect.html#LIBPQ-CONNECT-CLIENT-ENCODING"
>client_encoding</A
> connection parameter.
</P
></LI
></UL
><P>
</P
><P
> The following environment variables can be used to specify default
behavior for each <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> session. (See
also the <A
HREF="sql-alterrole.html"
>ALTER ROLE</A
>
and <A
HREF="sql-alterdatabase.html"
>ALTER DATABASE</A
>
commands for ways to set default behavior on a per-user or per-database
basis.)
<P
></P
></P><UL
><LI
><P
>
<TT
CLASS="ENVAR"
>PGDATESTYLE</TT
> sets the default style of date/time
representation. (Equivalent to <TT
CLASS="LITERAL"
>SET datestyle TO
...</TT
>.)
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGTZ</TT
> sets the default time zone. (Equivalent to
<TT
CLASS="LITERAL"
>SET timezone TO ...</TT
>.)
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGGEQO</TT
> sets the default mode for the genetic query
optimizer. (Equivalent to <TT
CLASS="LITERAL"
>SET geqo TO ...</TT
>.)
</P
></LI
></UL
><P>
Refer to the <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
> command <A
HREF="sql-set.html"
>SET</A
>
for information on correct values for these
environment variables.
</P
><P
> The following environment variables determine internal behavior of
<SPAN
CLASS="APPLICATION"
>libpq</SPAN
>; they override compiled-in defaults.
<P
></P
></P><UL
><LI
><P
>
<TT
CLASS="ENVAR"
>PGSYSCONFDIR</TT
> sets the directory containing the
<TT
CLASS="FILENAME"
>pg_service.conf</TT
> file and in a future version
possibly other system-wide configuration files.
</P
></LI
><LI
><P
>
<TT
CLASS="ENVAR"
>PGLOCALEDIR</TT
> sets the directory containing the
<TT
CLASS="LITERAL"
>locale</TT
> files for message internationalization.
</P
></LI
></UL
><P>
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="libpq-events.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="libpq-pgpass.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Event System</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="libpq.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>The Password File</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>