<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >postgres</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 8.0.11 Documentation" HREF="index.html"><LINK REL="UP" TITLE="PostgreSQL Server Applications" HREF="reference-server.html"><LINK REL="PREVIOUS" TITLE="pg_resetxlog" HREF="app-pgresetxlog.html"><LINK REL="NEXT" TITLE="postmaster" HREF="app-postmaster.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="2007-02-02T03:57:22"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" >PostgreSQL 8.0.11 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="app-pgresetxlog.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="app-pgresetxlog.html" >Fast Backward</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="app-postmaster.html" >Fast Forward</A ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="app-postmaster.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="APP-POSTGRES" ></A ><SPAN CLASS="APPLICATION" >postgres</SPAN ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN50929" ></A ><H2 >Name</H2 >postgres -- run a <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > server in single-user mode</DIV ><A NAME="AEN50933" ></A ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN50935" ></A ><H2 >Synopsis</H2 ><P ><TT CLASS="COMMAND" >postgres</TT > [-A 0 | 1 ] [-B <TT CLASS="REPLACEABLE" ><I >nbuffers</I ></TT >] [-c <TT CLASS="REPLACEABLE" ><I >name</I ></TT >=<TT CLASS="REPLACEABLE" ><I >value</I ></TT >] [-d <TT CLASS="REPLACEABLE" ><I >debug-level</I ></TT >] [--describe-config] [-D <TT CLASS="REPLACEABLE" ><I >datadir</I ></TT >] [-e] [-E] [-f s | i | t | n | m | h ] [-F] [-N] [-o <TT CLASS="REPLACEABLE" ><I >filename</I ></TT >] [-O] [-P] [-s | -t pa | pl | ex ] [-S <TT CLASS="REPLACEABLE" ><I >work-mem</I ></TT >] [-W <TT CLASS="REPLACEABLE" ><I >seconds</I ></TT >] [--<TT CLASS="REPLACEABLE" ><I >name</I ></TT >=<TT CLASS="REPLACEABLE" ><I >value</I ></TT >] <TT CLASS="REPLACEABLE" ><I >database</I ></TT > <BR><TT CLASS="COMMAND" >postgres</TT > [-A 0 | 1 ] [-B <TT CLASS="REPLACEABLE" ><I >nbuffers</I ></TT >] [-c <TT CLASS="REPLACEABLE" ><I >name</I ></TT >=<TT CLASS="REPLACEABLE" ><I >value</I ></TT >] [-d <TT CLASS="REPLACEABLE" ><I >debug-level</I ></TT >] [-D <TT CLASS="REPLACEABLE" ><I >datadir</I ></TT >] [-e] [-f s | i | t | n | m | h ] [-F] [-o <TT CLASS="REPLACEABLE" ><I >filename</I ></TT >] [-O] [-p <TT CLASS="REPLACEABLE" ><I >database</I ></TT >] [-P] [-s | -t pa | pl | ex ] [-S <TT CLASS="REPLACEABLE" ><I >work-mem</I ></TT >] [-v <TT CLASS="REPLACEABLE" ><I >protocol</I ></TT >] [-W <TT CLASS="REPLACEABLE" ><I >seconds</I ></TT >] [--<TT CLASS="REPLACEABLE" ><I >name</I ></TT >=<TT CLASS="REPLACEABLE" ><I >value</I ></TT >]</P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN51031" ></A ><H2 >Description</H2 ><P > The <TT CLASS="COMMAND" >postgres</TT > executable is the actual <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > server process that processes queries. It is normally not called directly; instead a <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > multiuser server is started. </P ><P > The second form above is how <TT CLASS="COMMAND" >postgres</TT > is invoked by the <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > (only conceptually, since both <TT CLASS="FILENAME" >postmaster</TT > and <TT CLASS="FILENAME" >postgres</TT > are in fact the same program); it should not be invoked directly this way. The first form invokes the server directly in interactive single-user mode. The primary use for this mode is during bootstrapping by <A HREF="app-initdb.html" >initdb</A >. Sometimes it is used for debugging or disaster recovery. </P ><P > When invoked in interactive 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. But note that running a single-user server is not truly suitable for debugging the server since no realistic interprocess communication and locking will happen. </P ><P > When running a stand-alone server, the session user will be set to the user with ID 1. This user does not actually have to exist, so a stand-alone server can be used to manually recover from certain kinds of accidental damage to the system catalogs. Implicit superuser powers are granted to the user with ID 1 in stand-alone mode. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN51045" ></A ><H2 >Options</H2 ><P > When <TT CLASS="COMMAND" >postgres</TT > is started by a <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > then it inherits all options set by the latter. Additionally, <TT CLASS="COMMAND" >postgres</TT >-specific options can be passed from the <TT CLASS="COMMAND" >postmaster</TT > with the <TT CLASS="OPTION" >-o</TT > switch. </P ><P > You can avoid having to type these options by setting up a configuration file. See <A HREF="runtime-config.html" >Section 16.4</A > for details. Some (safe) options can also be set from the connecting client in an application-dependent way. For example, if the environment variable <TT CLASS="ENVAR" >PGOPTIONS</TT > is set, then <SPAN CLASS="APPLICATION" >libpq</SPAN >-based clients will pass that string to the server, which will interpret it as <TT CLASS="COMMAND" >postgres</TT > command-line options. </P ><DIV CLASS="REFSECT2" ><A NAME="AEN51058" ></A ><H3 >General Purpose</H3 ><P > The options <TT CLASS="OPTION" >-A</TT >, <TT CLASS="OPTION" >-B</TT >, <TT CLASS="OPTION" >-c</TT >, <TT CLASS="OPTION" >-d</TT >, <TT CLASS="OPTION" >-D</TT >, <TT CLASS="OPTION" >-F</TT >, and <TT CLASS="OPTION" >--<TT CLASS="REPLACEABLE" ><I >name</I ></TT ></TT > have the same meanings as the <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > except that <TT CLASS="LITERAL" >-d 0</TT > prevents the server log level of the <TT CLASS="COMMAND" >postmaster</TT > from being propagated to <TT CLASS="COMMAND" >postgres</TT >. </P ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="OPTION" >-e</TT ></DT ><DD ><P > Sets the default date style to <SPAN CLASS="QUOTE" >"European"</SPAN >, that is <TT CLASS="LITERAL" >DMY</TT > ordering of input date fields. This also causes the day to be printed before the month in certain date output formats. See <A HREF="datatype-datetime.html" >Section 8.5</A > for more information. </P ></DD ><DT ><TT CLASS="OPTION" >-o</TT > <TT CLASS="REPLACEABLE" ><I >filename</I ></TT ></DT ><DD ><P > Send all server log output to <TT CLASS="REPLACEABLE" ><I >filename</I ></TT >. If <TT CLASS="COMMAND" >postgres</TT > is running under the <TT CLASS="COMMAND" >postmaster</TT >, this option is ignored, and the <SPAN CLASS="SYSTEMITEM" >stderr</SPAN > inherited from the <TT CLASS="COMMAND" >postmaster</TT > is used. </P ></DD ><DT ><TT CLASS="OPTION" >-P</TT ></DT ><DD ><P > Ignore system indexes when reading system tables (but still update the indexes when modifying the tables). This is useful when recovering from damaged system indexes. </P ></DD ><DT ><TT CLASS="OPTION" >-s</TT ></DT ><DD ><P > Print time information and other statistics at the end of each command. This is useful for benchmarking or for use in tuning the number of buffers. </P ></DD ><DT ><TT CLASS="OPTION" >-S</TT > <TT CLASS="REPLACEABLE" ><I >work-mem</I ></TT ></DT ><DD ><P > Specifies the amount of memory to be used by internal sorts and hashes before resorting to temporary disk files. See the description of the <TT CLASS="VARNAME" >work_mem</TT > configuration parameter in <A HREF="runtime-config.html#RUNTIME-CONFIG-RESOURCE-MEMORY" >Section 16.4.3.1</A >. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT2" ><A NAME="AEN51111" ></A ><H3 >Options for stand-alone mode</H3 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="REPLACEABLE" ><I >database</I ></TT ></DT ><DD ><P > Specifies the name of the database to be accessed. If it is omitted it defaults to the user name. </P ></DD ><DT ><TT CLASS="OPTION" >-E</TT ></DT ><DD ><P > Echo all commands. </P ></DD ><DT ><TT CLASS="OPTION" >-N</TT ></DT ><DD ><P > Disables use of newline as a statement delimiter. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT2" ><A NAME="AEN51129" ></A ><H3 >Semi-internal Options</H3 ><P > There are several other options that may be specified, used mainly for debugging purposes. These are listed here only for the use by <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > system developers. <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Use of any of these options is highly discouraged.</I ></SPAN > Furthermore, any of these options may disappear or change in a future release without notice. </P ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="OPTION" >-f</TT > <TT CLASS="LITERAL" >{ s | i | m | n | h }</TT ></DT ><DD ><P > Forbids the use of particular scan and join methods: <TT CLASS="LITERAL" >s</TT > and <TT CLASS="LITERAL" >i</TT > disable sequential and index scans respectively, while <TT CLASS="LITERAL" >n</TT >, <TT CLASS="LITERAL" >m</TT >, and <TT CLASS="LITERAL" >h</TT > disable nested-loop, merge and hash joins respectively. </P ><DIV CLASS="NOTE" ><BLOCKQUOTE CLASS="NOTE" ><P ><B >Note: </B > Neither sequential scans nor nested-loop joins can be disabled completely; the <TT CLASS="LITERAL" >-fs</TT > and <TT CLASS="LITERAL" >-fn</TT > options simply discourage the optimizer from using those plan types if it has any other alternative. </P ></BLOCKQUOTE ></DIV ></DD ><DT ><TT CLASS="OPTION" >-O</TT ></DT ><DD ><P > Allows the structure of system tables to be modified. This is used by <TT CLASS="COMMAND" >initdb</TT >. </P ></DD ><DT ><TT CLASS="OPTION" >-p</TT > <TT CLASS="REPLACEABLE" ><I >database</I ></TT ></DT ><DD ><P > Indicates that this process has been started by a <TT CLASS="COMMAND" >postmaster</TT > and specifies the database to use. etc. </P ></DD ><DT ><TT CLASS="OPTION" >-t</TT > <TT CLASS="LITERAL" >pa[rser] | pl[anner] | e[xecutor]</TT ></DT ><DD ><P > Print timing statistics for each query relating to each of the major system modules. This option cannot be used together with the <TT CLASS="OPTION" >-s</TT > option. </P ></DD ><DT ><TT CLASS="OPTION" >-v</TT > <TT CLASS="REPLACEABLE" ><I >protocol</I ></TT ></DT ><DD ><P > Specifies the version number of the frontend/backend protocol to be used for this particular session. </P ></DD ><DT ><TT CLASS="OPTION" >-W</TT > <TT CLASS="REPLACEABLE" ><I >seconds</I ></TT ></DT ><DD ><P > As soon as this option is encountered, the process sleeps for the specified amount of seconds. This gives developers time to attach a debugger to the server process. </P ></DD ><DT ><TT CLASS="OPTION" >--describe-config</TT ></DT ><DD ><P > This option dumps out the server's internal configuration variables, descriptions, and defaults in tab-delimited <TT CLASS="COMMAND" >COPY</TT > format. It is designed primarily for use by administration tools. </P ></DD ></DL ></DIV ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN51188" ></A ><H2 >Environment</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="ENVAR" >PGDATA</TT ></DT ><DD ><P > Default data directory location </P ></DD ></DL ></DIV ><P > For others, which have little influence during single-user mode, see <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A >. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN51198" ></A ><H2 >Notes</H2 ><P > To cancel a running query, send the <TT CLASS="LITERAL" >SIGINT</TT > signal to the <TT CLASS="COMMAND" >postgres</TT > process running that command. </P ><P > To tell <TT CLASS="COMMAND" >postgres</TT > to reload the configuration files, send a <TT CLASS="LITERAL" >SIGHUP</TT > signal. Normally it's best to <TT CLASS="LITERAL" >SIGHUP</TT > the <TT CLASS="COMMAND" >postmaster</TT > instead; the <TT CLASS="COMMAND" >postmaster</TT > will in turn <TT CLASS="LITERAL" >SIGHUP</TT > each of its children. But in some cases it might be desirable to have only one <TT CLASS="COMMAND" >postgres</TT > process reload the configuration files. </P ><P > The <TT CLASS="COMMAND" >postmaster</TT > uses <TT CLASS="LITERAL" >SIGTERM</TT > to tell a <TT CLASS="COMMAND" >postgres</TT > process to quit normally and <TT CLASS="LITERAL" >SIGQUIT</TT > to terminate without the normal cleanup. These signals <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >should not</I ></SPAN > be used by users. It is also unwise to send <TT CLASS="LITERAL" >SIGKILL</TT > to a <TT CLASS="COMMAND" >postgres</TT > process — the <TT CLASS="COMMAND" >postmaster</TT > will interpret this as a crash in <TT CLASS="COMMAND" >postgres</TT >, and will force all the sibling <TT CLASS="COMMAND" >postgres</TT > processes to quit as part of its standard crash-recovery procedure. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN51222" ></A ><H2 >Usage</H2 ><P > Start a stand-alone server with a command like </P><PRE CLASS="SCREEN" ><KBD CLASS="USERINPUT" >postgres -D /usr/local/pgsql/data <TT CLASS="REPLACEABLE" ><I >other-options</I ></TT > my_database</KBD ></PRE ><P> Provide the correct path to the database directory with <TT CLASS="OPTION" >-D</TT >, or make sure that the environment variable <TT CLASS="ENVAR" >PGDATA</TT > is set. Also specify the name of the particular database you want to work in. </P ><P > Normally, the stand-alone server treats newline as the command entry terminator; there is no intelligence about semicolons, as there is in <SPAN CLASS="APPLICATION" >psql</SPAN >. To continue a command across multiple lines, you must type backslash just before each newline except the last one. </P ><P > But if you use the <TT CLASS="OPTION" >-N</TT > command line switch, then newline does not terminate command entry. In this case, the server will read the standard input until the end-of-file (<ACRONYM CLASS="ACRONYM" >EOF</ACRONYM >) marker, then process the input as a single command string. Backslash-newline is not treated specially in this case. </P ><P > To quit the session, type <ACRONYM CLASS="ACRONYM" >EOF</ACRONYM > (<B CLASS="KEYCAP" >Control</B >+<B CLASS="KEYCAP" >D</B >, usually). If you've used <TT CLASS="OPTION" >-N</TT >, two consecutive <ACRONYM CLASS="ACRONYM" >EOF</ACRONYM >s are needed to exit. </P ><P > Note that the stand-alone server does not provide sophisticated line-editing features (no command history, for example). </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN51243" ></A ><H2 >See Also</H2 ><P > <A HREF="app-initdb.html" >initdb</A >, <A HREF="app-ipcclean.html" ><SPAN CLASS="APPLICATION" >ipcclean</SPAN ></A >, <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > </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="app-pgresetxlog.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="app-postmaster.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><SPAN CLASS="APPLICATION" >pg_resetxlog</SPAN ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="reference-server.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >