postgres 1 Application postgres run a PostgreSQL server in single-user mode postgres (the program) postgres option database Description The postgres executable is the actual PostgreSQL server process that processes SQL statements. It is normally not called directly; instead a multiuser server is started. Conceptually, the postmaster starts a new postgres process for each connection. (postmaster and postgres are in fact the same program, and on most platforms the connection process is forked). If the postgres command is called directly, it invokes the server in interactive single-user mode. The primary use for this mode is during bootstrapping by . Sometimes it is used for debugging or disaster recovery. 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. 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. Options When postgres is started by a then it inherits all options set by the latter. In single-user mode, postgres accepts all the options that postmaster would accept. You can avoid having to type these options by setting up a configuration file. See for details. Some (safe) options can also be set from the connecting client in an application-dependent way. For example, if the environment variable PGOPTIONS is set, then libpq-based clients will pass that string to the server, which will interpret it as postgres command-line options. General Purpose The options , , , , , , , , , and have the same meanings as with the except that -d 0 prevents the server log level of the postmaster from being propagated to postgres. Other postmaster options are also accepted but will have no noticeable effect because they only apply to the multiuser server mode, namely , , , , and . Options for stand-alone mode database Specifies the name of the database to be accessed. If it is omitted it defaults to the user name. Echo all commands. Disables use of newline as a statement delimiter. filename Send all server log output to filename. If postgres is running under the postmaster, this option is ignored, and the stderr inherited from the postmaster is used. Semi-internal Options The options , , , , and have the same meanings as with the and are reserved for debugging and disaster recovery. Further options for internal use are: protocol Specifies the version number of the frontend/backend protocol to be used for this particular session. database Indicates that this process has been started by a postmaster and specifies the database to use. etc. This option dumps out the server's internal configuration variables, descriptions, and defaults in tab-delimited COPY format. It is designed primarily for use by administration tools. Environment PGDATA Default data directory location Notes To cancel a running query, send the SIGINT signal to the postgres process running that command. To tell postgres to reload the configuration files, send a SIGHUP signal. Normally it's best to SIGHUP the postmaster instead; the postmaster will in turn SIGHUP each of its children. But in some cases it might be desirable to have only one postgres process reload the configuration files. The postmaster uses SIGTERM to tell a postgres process to quit normally and SIGQUIT to terminate without the normal cleanup. These signals should not be used by users. It is also unwise to send SIGKILL to a postgres process — the postmaster will interpret this as a crash in postgres, and will force all the sibling postgres processes to quit as part of its standard crash-recovery procedure. Usage Start a stand-alone server with a command like postgres -D /usr/local/pgsql/data other-options my_database Provide the correct path to the database directory with Normally, the stand-alone server treats newline as the command entry terminator; there is no intelligence about semicolons, as there is in psql. To continue a command across multiple lines, you must type backslash just before each newline except the last one. But if you use the To quit the session, type EOF (ControlD, usually). If you've used Note that the stand-alone server does not provide sophisticated line-editing features (no command history, for example). See Also , ,