3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "POSTGRES" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 postgres \- PostgreSQL database server
33 .HP \w'\fBpostgres\fR\ 'u
34 \fBpostgres\fR [\fIoption\fR...]
40 database server\&. In order for a client application to access a database it connects (over a network or locally) to a running
44 instance then starts a separate server process to handle the connection\&.
48 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
49 \(lqdata area\(rq)\&. More than one
51 instance can run on a system at one time, so long as they use different data areas and different communication ports (see below)\&. When
53 starts it needs to know the location of the data area\&. The location must be specified by the
57 environment variable; there is no default\&. Typically,
61 points directly to the data area directory created by
62 \fBinitdb\fR(1)\&. Other possible file layouts are discussed in
67 starts in the foreground and prints log messages to the standard error stream\&. In practical applications
69 should be started as a background process, perhaps at boot time\&.
73 command can also be called in single\-user mode\&. The primary use for this mode is during bootstrapping by
74 \fBinitdb\fR(1)\&. 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\&.
78 accepts the following command\-line arguments\&. For a detailed discussion of the options consult
79 Chapter\ \&19\&. 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
82 libpq\-based clients will pass that string to the server, which will interpret it as
84 command\-line options\&.
87 \fB\-B \fR\fB\fInbuffers\fR\fR
89 Sets the number of shared buffers for use by the server processes\&. The default value of this parameter is chosen automatically by
90 initdb\&. Specifying this option is equivalent to setting the
92 configuration parameter\&.
95 \fB\-c \fR\fB\fIname\fR\fR\fB=\fR\fB\fIvalue\fR\fR
97 Sets a named run\-time parameter\&. The configuration parameters supported by
100 Chapter\ \&19\&. Most of the other command line options are in fact short forms of such a parameter assignment\&.
102 can appear multiple times to set multiple parameters\&.
105 \fB\-C \fR\fB\fIname\fR\fR
107 Prints the value of the named run\-time parameter, and exits\&. (See the
109 option above for details\&.) This returns values from
110 postgresql\&.conf, modified by any parameters supplied in this invocation\&. It does not reflect parameters supplied when the cluster was started\&.
112 This can be used on a running server for most parameters\&. However, the server must be shut down for some runtime\-computed parameters (e\&.g\&.,
114 shared_memory_size_in_huge_pages, and
117 This option is meant for other programs that interact with a server instance, such as
118 \fBpg_ctl\fR(1), to query configuration parameter values\&. User\-facing applications should instead use
125 \fB\-d \fR\fB\fIdebug\-level\fR\fR
127 Sets the debug level\&. The higher this value is set, the more debugging output is written to the server log\&. Values are from 1 to 5\&. It is also possible to pass
129 for a specific session, which will prevent the server log level of the parent
131 process from being propagated to this session\&.
134 \fB\-D \fR\fB\fIdatadir\fR\fR
136 Specifies the file system location of the database configuration files\&. See
143 Sets the default date style to
144 \(lqEuropean\(rq, that is
146 ordering of input date fields\&. This also causes the day to be printed before the month in certain date output formats\&. See
148 for more information\&.
155 calls for improved performance, at the risk of data corruption in the event of a system crash\&. Specifying this option is equivalent to disabling the
157 configuration parameter\&. Read the detailed documentation before using this!
160 \fB\-h \fR\fB\fIhostname\fR\fR
162 Specifies the IP host name or address on which
164 is to listen for TCP/IP connections from client applications\&. The value can also be a comma\-separated list of addresses, or
166 to specify listening on all available interfaces\&. An empty value specifies not listening on any IP addresses, in which case only Unix\-domain sockets can be used to connect to the server\&. Defaults to listening only on
167 localhost\&. Specifying this option is equivalent to setting the
169 configuration parameter\&.
174 Allows remote clients to connect via TCP/IP (Internet domain) connections\&. Without this option, only local connections are accepted\&. This option is equivalent to setting
175 \fIlisten_addresses\fR
183 This option is deprecated since it does not allow access to the full functionality of
184 listen_addresses\&. It\*(Aqs usually better to set
185 \fIlisten_addresses\fR
189 \fB\-k \fR\fB\fIdirectory\fR\fR
191 Specifies the directory of the Unix\-domain socket on which
193 is to listen for connections from client applications\&. The value can also be a comma\-separated list of directories\&. An empty value specifies not listening on any Unix\-domain sockets, in which case only TCP/IP sockets can be used to connect to the server\&. The default value is normally
194 /tmp, but that can be changed at build time\&. Specifying this option is equivalent to setting the
195 unix_socket_directories
196 configuration parameter\&.
201 Enables secure connections using
204 must have been compiled with support for
206 for this option to be available\&. For more information on using
211 \fB\-N \fR\fB\fImax\-connections\fR\fR
213 Sets the maximum number of client connections that this server will accept\&. The default value of this parameter is chosen automatically by
214 initdb\&. Specifying this option is equivalent to setting the
216 configuration parameter\&.
219 \fB\-p \fR\fB\fIport\fR\fR
221 Specifies the TCP/IP port or local Unix domain socket file extension on which
223 is to listen for connections from client applications\&. Defaults to the value of the
225 environment variable, or if
227 is not set, then defaults to the value established during compilation (normally 5432)\&. If you specify a port other than the default port, then all client applications must specify the same port using either command\-line options or
233 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\&.
236 \fB\-S\fR \fIwork\-mem\fR
238 Specifies the base amount of memory to be used by sorts and hash tables before resorting to temporary disk files\&. See the description of the
240 configuration parameter in
253 \fB\-\-\fR\fB\fIname\fR\fR\fB=\fR\fB\fIvalue\fR\fR
255 Sets a named run\-time parameter; a shorter form of
259 \fB\-\-describe\-config\fR
261 This option dumps out the server\*(Aqs internal configuration variables, descriptions, and defaults in tab\-delimited
263 format\&. It is designed primarily for use by administration tools\&.
272 command line arguments, and exit\&.
274 .SS "Semi\-Internal Options"
276 The options described here are used mainly for debugging purposes, and in some cases to assist with recovery of severely damaged databases\&. There should be no reason to use them in a production database setup\&. They are listed here only for use by
278 system developers\&. Furthermore, these options might change or be removed in a future release without notice\&.
280 \fB\-f\fR { s | i | o | b | t | n | m | h }
282 Forbids the use of particular scan and join methods:
286 disable sequential and index scans respectively,
291 disable index\-only scans, bitmap index scans, and TID scans respectively, while
295 disable nested\-loop, merge and hash joins respectively\&.
297 Neither sequential scans nor nested\-loop joins can be disabled completely; the
301 options simply discourage the optimizer from using those plan types if it has any other alternative\&.
306 Allows the structure of system tables to be modified\&. This is used by
312 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\&.
315 \fB\-t\fR pa[rser] | pl[anner] | e[xecutor]
317 Print timing statistics for each query relating to each of the major system modules\&. This option cannot be used together with the
324 This option is for debugging problems that cause a server process to die abnormally\&. The ordinary strategy in this situation is to notify all other server processes that they must terminate, by sending them
326 signals\&. With this option,
328 will be sent instead, resulting in production of core dump files\&.
331 \fB\-v\fR \fIprotocol\fR
333 Specifies the version number of the frontend/backend protocol to be used for a particular session\&. This option is for internal use only\&.
336 \fB\-W\fR \fIseconds\fR
338 A delay of this many seconds occurs when a new server process is started, after it conducts the authentication procedure\&. This is intended to give an opportunity to attach to the server process with a debugger\&.
340 .SS "Options for Single\-User Mode"
342 The following options only apply to the single\-user mode (see
348 Selects the single\-user mode\&. This must be the first argument on the command line\&.
353 Specifies the name of the database to be accessed\&. This must be the last argument on the command line\&. If it is omitted it defaults to the user name\&.
358 Echo all commands to standard output before executing them\&.
363 Use semicolon followed by two newlines, rather than just newline, as the command entry terminator\&.
366 \fB\-r\fR \fIfilename\fR
368 Send all server log output to
369 \fIfilename\fR\&. This option is only honored when supplied as a command\-line option\&.
373 \fBPGCLIENTENCODING\fR
375 Default character encoding used by clients\&. (The clients can override this individually\&.) This value can also be set in the configuration file\&.
380 Default data directory location
387 run\-time parameter\&. (The use of this environment variable is deprecated\&.)
392 Default port number (preferably set in the configuration file)
396 A failure message mentioning
400 probably indicates you need to configure your kernel to provide adequate shared memory and semaphores\&. For more discussion see
401 Section\ \&18.4\&. You might be able to postpone reconfiguring your kernel by decreasing
403 to reduce the shared memory consumption of
404 PostgreSQL, and/or by reducing
406 to reduce the semaphore consumption\&.
408 A failure message suggesting that another server is already running should be checked carefully, for example by using the command
414 $ \fBps ax | grep postgres\fR
426 $ \fBps \-ef | grep postgres\fR
432 depending on your system\&. If you are certain that no conflicting server is running, you can remove the lock file mentioned in the message and try again\&.
434 A failure message indicating inability to bind to a port might indicate that that port is already in use by some non\-PostgreSQL
435 process\&. You might also get this error if you terminate
437 and immediately restart it using the same port; in this case, you must simply wait a few seconds until the operating system closes the port before trying again\&. Finally, you might get this error if you specify a port number that your operating system considers to be reserved\&. For example, many versions of Unix consider port numbers under 1024 to be
439 and only permit the Unix superuser to access them\&.
444 can be used to start and shut down the
446 server safely and comfortably\&.
454 server\&. Doing so will prevent
456 from freeing the system resources (e\&.g\&., shared memory and semaphores) that it holds before terminating\&. This might cause problems for starting a fresh
462 server normally, the signals
466 can be used\&. The first will wait for all clients to terminate before quitting, the second will forcefully disconnect all clients, and the third will quit immediately without proper shutdown, resulting in a recovery run during restart\&.
470 signal will reload the server configuration files\&. It is also possible to send
472 to an individual server process, but that is usually not sensible\&.
474 To cancel a running query, send the
476 signal to the process running that command\&. To terminate a backend process cleanly, send
478 to that process\&. See also
479 \fBpg_cancel_backend\fR
481 \fBpg_terminate_backend\fR
484 for the SQL\-callable equivalents of these two actions\&.
490 to tell subordinate server processes to terminate without normal cleanup\&. This signal
492 be used by users\&. It is also unwise to send
494 to a server process \(em the main
496 process will interpret this as a crash and will force all the sibling processes to quit as part of its standard crash\-recovery procedure\&.
501 options will not work on
506 instead\&. This is a bug in the affected operating systems; a future release of
508 will provide a workaround if this is not fixed\&.
509 .SH "SINGLE\-USER MODE"
511 To start a single\-user mode server, use a command like
517 \fBpostgres \-\-single \-D /usr/local/pgsql/data \fR\fB\fIother\-options\fR\fR\fB my_database\fR
523 Provide the correct path to the database directory with
524 \fB\-D\fR, or make sure that the environment variable
526 is set\&. Also specify the name of the particular database you want to work in\&.
528 Normally, the single\-user mode server treats newline as the command entry terminator; there is no intelligence about semicolons, as there is in
529 psql\&. To continue a command across multiple lines, you must type backslash just before each newline except the last one\&. The backslash and adjacent newline are both dropped from the input command\&. Note that this will happen even when within a string literal or comment\&.
533 command line switch, a single newline does not terminate command entry; instead, the sequence semicolon\-newline\-newline does\&. That is, type a semicolon immediately followed by a completely empty line\&. Backslash\-newline is not treated specially in this mode\&. Again, there is no intelligence about such a sequence appearing within a string literal or comment\&.
535 In either input mode, if you type a semicolon that is not just before or part of a command entry terminator, it is considered a command separator\&. When you do type a command entry terminator, the multiple statements you\*(Aqve entered will be executed as a single transaction\&.
537 To quit the session, type
539 (Control+D, usually)\&. If you\*(Aqve entered any text since the last command entry terminator, then
541 will be taken as a command entry terminator, and another
543 will be needed to exit\&.
545 Note that the single\-user mode server does not provide sophisticated line\-editing features (no command history, for example)\&. Single\-user mode also does not do any background processing, such as automatic checkpoints or replication\&.
550 in the background using default values, type:
556 $ \fBnohup postgres >logfile 2>&1 </dev/null &\fR
564 with a specific port, e\&.g\&., 1234:
570 $ \fBpostgres \-p 1234\fR
576 To connect to this server using
577 psql, specify this port with the \-p option:
583 $ \fBpsql \-p 1234\fR
589 or set the environment variable
596 $ \fBexport PGPORT=1234\fR
603 Named run\-time parameters can be set in either of these styles:
609 $ \fBpostgres \-c work_mem=1234\fR
610 $ \fBpostgres \-\-work\-mem=1234\fR
616 Either form overrides whatever setting might exist for
619 postgresql\&.conf\&. Notice that underscores in parameter names can be written as either underscore or dash on the command line\&. Except for short\-term experiments, it\*(Aqs probably better practice to edit the setting in
621 than to rely on a command\-line switch to set a parameter\&.