<!--
doc/src/sgml/ref/postgres-ref.sgml
PostgreSQL documentation
-->
<refentry id="app-postgres">
<indexterm zone="app-postgres">
<primary>postgres</primary>
</indexterm>
<refmeta>
<refentrytitle><application>postgres</application></refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname>postgres</refname>
<refpurpose><productname>PostgreSQL</productname> database server</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>postgres</command>
<arg rep="repeat"><replaceable>option</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>postgres</command> is the
<productname>PostgreSQL</productname> database server. In order
for a client application to access a database it connects (over a
network or locally) to a running <command>postgres</command> instance.
The <command>postgres</command> instance then starts a separate server
process to handle the connection.
</para>
<para>
One <command>postgres</command> instance always manages the data of
exactly one database cluster. A database cluster is a collection
of databases that is stored at a common file system location (the
<quote>data area</quote>). More than one
<command>postgres</command> instance can run on a system at one
time, so long as they use different data areas and different
communication ports (see below). When
<command>postgres</command> starts it needs to know the location
of the data area. The location must be specified by the
<option>-D</option> option or the <envar>PGDATA</envar> environment
variable; there is no default. Typically, <option>-D</option> or
<envar>PGDATA</envar> points directly to the data area directory
created by <xref linkend="app-initdb"/>. Other possible file layouts are
discussed in <xref linkend="runtime-config-file-locations"/>.
</para>
<para>
By default <command>postgres</command> starts in the
foreground and prints log messages to the standard error stream. In
practical applications <command>postgres</command>
should be started as a background process, perhaps at boot time.
</para>
<para>
The <command>postgres</command> command can also be called in
single-user mode. The primary use for this mode is during
bootstrapping by <xref linkend="app-initdb"/>. Sometimes it is used
for debugging or disaster recovery; note that running a single-user
server is not truly suitable for debugging the server, since no
realistic interprocess communication and locking will happen.
When invoked in single-user
mode from the shell, the user can enter queries and the results
will be printed to the screen, but in a form that is more useful
for developers than end users. In the single-user mode,
the session user will be set to the user with ID 1, and implicit
superuser powers are granted to this user.
This user does not actually have to exist, so the single-user mode
can be used to manually recover from certain
kinds of accidental damage to the system catalogs.
</para>
</refsect1>
<refsect1 id="app-postgres-options">
<title>Options</title>
<para>
<command>postgres</command> accepts the following command-line
arguments. For a detailed discussion of the options consult <xref
linkend="runtime-config"/>. You can save typing most of these
options by setting up a configuration file. Some (safe) options
can also be set from the connecting client in an
application-dependent way to apply only for that session. For
example, if the environment variable <envar>PGOPTIONS</envar> is
set, then <application>libpq</application>-based clients will pass that
string to the server, which will interpret it as
<command>postgres</command> command-line options.
</para>
<refsect2>
<title>General Purpose</title>
<variablelist>