1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>postgres</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgwalsummary.html" title="pg_walsummary" /><link rel="next" href="internals.html" title="Part VII. Internals" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">postgres</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgwalsummary.html" title="pg_walsummary">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="internals.html" title="Part VII. Internals">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-POSTGRES"><div class="titlepage"></div><a id="id-1.9.5.16.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">postgres</span></span></h2><p>postgres — <span class="productname">PostgreSQL</span> database server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.16.4.1"><code class="command">postgres</code> [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="id-1.9.5.16.5"><h2>Description</h2><p>
3 <code class="command">postgres</code> is the
4 <span class="productname">PostgreSQL</span> database server. In order
5 for a client application to access a database it connects (over a
6 network or locally) to a running <code class="command">postgres</code> instance.
7 The <code class="command">postgres</code> instance then starts a separate server
8 process to handle the connection.
10 One <code class="command">postgres</code> instance always manages the data of
11 exactly one database cluster. A database cluster is a collection
12 of databases that is stored at a common file system location (the
13 <span class="quote">“<span class="quote">data area</span>”</span>). More than one
14 <code class="command">postgres</code> instance can run on a system at one
15 time, so long as they use different data areas and different
16 communication ports (see below). When
17 <code class="command">postgres</code> starts it needs to know the location
18 of the data area. The location must be specified by the
19 <code class="option">-D</code> option or the <code class="envar">PGDATA</code> environment
20 variable; there is no default. Typically, <code class="option">-D</code> or
21 <code class="envar">PGDATA</code> points directly to the data area directory
22 created by <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>. Other possible file layouts are
23 discussed in <a class="xref" href="runtime-config-file-locations.html" title="19.2. File Locations">Section 19.2</a>.
25 By default <code class="command">postgres</code> starts in the
26 foreground and prints log messages to the standard error stream. In
27 practical applications <code class="command">postgres</code>
28 should be started as a background process, perhaps at boot time.
30 The <code class="command">postgres</code> command can also be called in
31 single-user mode. The primary use for this mode is during
32 bootstrapping by <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>. Sometimes it is used
33 for debugging or disaster recovery; note that running a single-user
34 server is not truly suitable for debugging the server, since no
35 realistic interprocess communication and locking will happen.
36 When invoked in single-user
37 mode from the shell, the user can enter queries and the results
38 will be printed to the screen, but in a form that is more useful
39 for developers than end users. In the single-user mode,
40 the session user will be set to the user with ID 1, and implicit
41 superuser powers are granted to this user.
42 This user does not actually have to exist, so the single-user mode
43 can be used to manually recover from certain
44 kinds of accidental damage to the system catalogs.
45 </p></div><div class="refsect1" id="APP-POSTGRES-OPTIONS"><h2>Options</h2><p>
46 <code class="command">postgres</code> accepts the following command-line
47 arguments. For a detailed discussion of the options consult <a class="xref" href="runtime-config.html" title="Chapter 19. Server Configuration">Chapter 19</a>. You can save typing most of these
48 options by setting up a configuration file. Some (safe) options
49 can also be set from the connecting client in an
50 application-dependent way to apply only for that session. For
51 example, if the environment variable <code class="envar">PGOPTIONS</code> is
52 set, then <span class="application">libpq</span>-based clients will pass that
53 string to the server, which will interpret it as
54 <code class="command">postgres</code> command-line options.
55 </p><div class="refsect2" id="id-1.9.5.16.6.3"><h3>General Purpose</h3><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-B <em class="replaceable"><code>nbuffers</code></em></code></span></dt><dd><p>
56 Sets the number of shared buffers for use by the server
57 processes. The default value of this parameter is chosen
58 automatically by <span class="application">initdb</span>.
59 Specifying this option is equivalent to setting the
60 <a class="xref" href="runtime-config-resource.html#GUC-SHARED-BUFFERS">shared_buffers</a> configuration parameter.
61 </p></dd><dt><span class="term"><code class="option">-c <em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code></span></dt><dd><p>
62 Sets a named run-time parameter. The configuration parameters
63 supported by <span class="productname">PostgreSQL</span> are
64 described in <a class="xref" href="runtime-config.html" title="Chapter 19. Server Configuration">Chapter 19</a>. Most of the
65 other command line options are in fact short forms of such a
66 parameter assignment. <code class="option">-c</code> can appear multiple times
67 to set multiple parameters.
68 </p></dd><dt><span class="term"><code class="option">-C <em class="replaceable"><code>name</code></em></code></span></dt><dd><p>
69 Prints the value of the named run-time parameter, and exits.
70 (See the <code class="option">-c</code> option above for details.) This
72 <code class="filename">postgresql.conf</code>, modified by any parameters
73 supplied in this invocation. It does not reflect parameters
74 supplied when the cluster was started.
76 This can be used on a running server for most parameters. However,
77 the server must be shut down for some runtime-computed parameters
78 (e.g., <a class="xref" href="runtime-config-preset.html#GUC-SHARED-MEMORY-SIZE">shared_memory_size</a>,
79 <a class="xref" href="runtime-config-preset.html#GUC-SHARED-MEMORY-SIZE-IN-HUGE-PAGES">shared_memory_size_in_huge_pages</a>, and
80 <a class="xref" href="runtime-config-preset.html#GUC-WAL-SEGMENT-SIZE">wal_segment_size</a>).
82 This option is meant for other programs that interact with a server
83 instance, such as <a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a>, to query configuration
84 parameter values. User-facing applications should instead use <a class="link" href="sql-show.html" title="SHOW"><code class="command">SHOW</code></a> or the <code class="structname">pg_settings</code> view.
85 </p></dd><dt><span class="term"><code class="option">-d <em class="replaceable"><code>debug-level</code></em></code></span></dt><dd><p>
86 Sets the debug level. The higher this value is set, the more
87 debugging output is written to the server log. Values are
88 from 1 to 5. It is also possible to pass <code class="literal">-d
89 0</code> for a specific session, which will prevent the
90 server log level of the parent <code class="command">postgres</code> process from being
91 propagated to this session.
92 </p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>datadir</code></em></code></span></dt><dd><p>
93 Specifies the file system location of the database
94 configuration files. See
95 <a class="xref" href="runtime-config-file-locations.html" title="19.2. File Locations">Section 19.2</a> for details.
96 </p></dd><dt><span class="term"><code class="option">-e</code></span></dt><dd><p>
97 Sets the default date style to <span class="quote">“<span class="quote">European</span>”</span>, that is
98 <code class="literal">DMY</code> ordering of input date fields. This also causes
99 the day to be printed before the month in certain date output formats.
100 See <a class="xref" href="datatype-datetime.html" title="8.5. Date/Time Types">Section 8.5</a> for more information.
101 </p></dd><dt><span class="term"><code class="option">-F</code></span></dt><dd><p>
102 Disables <code class="function">fsync</code> calls for improved
103 performance, at the risk of data corruption in the event of a
104 system crash. Specifying this option is equivalent to
105 disabling the <a class="xref" href="runtime-config-wal.html#GUC-FSYNC">fsync</a> configuration
106 parameter. Read the detailed documentation before using this!
107 </p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>hostname</code></em></code></span></dt><dd><p>
108 Specifies the IP host name or address on which
109 <code class="command">postgres</code> is to listen for TCP/IP
110 connections from client applications. The value can also be a
111 comma-separated list of addresses, or <code class="literal">*</code> to specify
112 listening on all available interfaces. An empty value
113 specifies not listening on any IP addresses, in which case
114 only Unix-domain sockets can be used to connect to the
115 server. Defaults to listening only on
116 <span class="systemitem">localhost</span>.
117 Specifying this option is equivalent to setting the <a class="xref" href="runtime-config-connection.html#GUC-LISTEN-ADDRESSES">listen_addresses</a> configuration parameter.
118 </p></dd><dt><span class="term"><code class="option">-i</code></span></dt><dd><p>
119 Allows remote clients to connect via TCP/IP (Internet domain)
120 connections. Without this option, only local connections are
121 accepted. This option is equivalent to setting
122 <code class="varname">listen_addresses</code> to <code class="literal">*</code> in
123 <code class="filename">postgresql.conf</code> or via <code class="option">-h</code>.
125 This option is deprecated since it does not allow access to the
126 full functionality of <a class="xref" href="runtime-config-connection.html#GUC-LISTEN-ADDRESSES">listen_addresses</a>.
127 It's usually better to set <code class="varname">listen_addresses</code> directly.
128 </p></dd><dt><span class="term"><code class="option">-k <em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
129 Specifies the directory of the Unix-domain socket on which
130 <code class="command">postgres</code> is to listen for
131 connections from client applications. The value can also be a
132 comma-separated list of directories. An empty value
133 specifies not listening on any Unix-domain sockets, in which case
134 only TCP/IP sockets can be used to connect to the server.
135 The default value is normally
136 <code class="filename">/tmp</code>, but that can be changed at build time.
137 Specifying this option is equivalent to setting the <a class="xref" href="runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORIES">unix_socket_directories</a> configuration parameter.
138 </p></dd><dt><span class="term"><code class="option">-l</code></span></dt><dd><p>
139 Enables secure connections using <acronym class="acronym">SSL</acronym>.
140 <span class="productname">PostgreSQL</span> must have been compiled with
141 support for <acronym class="acronym">SSL</acronym> for this option to be
142 available. For more information on using <acronym class="acronym">SSL</acronym>,
143 refer to <a class="xref" href="ssl-tcp.html" title="18.9. Secure TCP/IP Connections with SSL">Section 18.9</a>.
144 </p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>max-connections</code></em></code></span></dt><dd><p>
145 Sets the maximum number of client connections that this
146 server will accept. The default value of this parameter is chosen
147 automatically by <span class="application">initdb</span>.
148 Specifying this option is equivalent to setting the
149 <a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a> configuration parameter.
150 </p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
151 Specifies the TCP/IP port or local Unix domain socket file
152 extension on which <code class="command">postgres</code>
153 is to listen for connections from client applications.
154 Defaults to the value of the <code class="envar">PGPORT</code> environment
155 variable, or if <code class="envar">PGPORT</code> is not set, then
156 defaults to the value established during compilation (normally
157 5432). If you specify a port other than the default port,
158 then all client applications must specify the same port using
159 either command-line options or <code class="envar">PGPORT</code>.
160 </p></dd><dt><span class="term"><code class="option">-s</code></span></dt><dd><p>
161 Print time information and other statistics at the end of each command.
162 This is useful for benchmarking or for use in tuning the number of
164 </p></dd><dt><span class="term"><code class="option">-S</code> <em class="replaceable"><code>work-mem</code></em></span></dt><dd><p>
165 Specifies the base amount of memory to be used by sorts and
166 hash tables before resorting to temporary disk files. See the
167 description of the <code class="varname">work_mem</code> configuration
168 parameter in <a class="xref" href="runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY" title="19.4.1. Memory">Section 19.4.1</a>.
169 </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
170 Print the <span class="application">postgres</span> version and exit.
171 </p></dd><dt><span class="term"><code class="option">--<em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code></span></dt><dd><p>
172 Sets a named run-time parameter; a shorter form of
173 <code class="option">-c</code>.
174 </p></dd><dt><span class="term"><code class="option">--describe-config</code></span></dt><dd><p>
175 This option dumps out the server's internal configuration variables,
176 descriptions, and defaults in tab-delimited <code class="command">COPY</code> format.
177 It is designed primarily for use by administration tools.
178 </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
179 Show help about <span class="application">postgres</span> command line
181 </p></dd></dl></div></div><div class="refsect2" id="id-1.9.5.16.6.4"><h3>Semi-Internal Options</h3><p>
182 The options described here are used
183 mainly for debugging purposes, and in some cases to assist with
184 recovery of severely damaged databases. There should be no reason
185 to use them in a production database setup. They are listed
186 here only for use by <span class="productname">PostgreSQL</span>
187 system developers. Furthermore, these options might
188 change or be removed in a future release without notice.
189 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-f</code> <code class="literal">{ s | i | o | b | t | n | m | h }</code></span></dt><dd><p>
190 Forbids the use of particular scan and join methods:
191 <code class="literal">s</code> and <code class="literal">i</code>
192 disable sequential and index scans respectively,
193 <code class="literal">o</code>, <code class="literal">b</code> and <code class="literal">t</code>
194 disable index-only scans, bitmap index scans, and TID scans
196 <code class="literal">n</code>, <code class="literal">m</code>, and <code class="literal">h</code>
197 disable nested-loop, merge and hash joins respectively.
199 Neither sequential scans nor nested-loop joins can be disabled
200 completely; the <code class="literal">-fs</code> and
201 <code class="literal">-fn</code> options simply discourage the optimizer
202 from using those plan types if it has any other alternative.
203 </p></dd><dt><span class="term"><code class="option">-O</code></span></dt><dd><p>
204 Allows the structure of system tables to be modified. This is
205 used by <code class="command">initdb</code>.
206 </p></dd><dt><span class="term"><code class="option">-P</code></span></dt><dd><p>
207 Ignore system indexes when reading system tables, but still update
208 the indexes when modifying the tables. This is useful when
209 recovering from damaged system indexes.
210 </p></dd><dt><span class="term"><code class="option">-t</code> <code class="literal">pa[rser] | pl[anner] | e[xecutor]</code></span></dt><dd><p>
211 Print timing statistics for each query relating to each of the
212 major system modules. This option cannot be used together
213 with the <code class="option">-s</code> option.
214 </p></dd><dt><span class="term"><code class="option">-T</code></span></dt><dd><p>
215 This option is for debugging problems that cause a server
216 process to die abnormally. The ordinary strategy in this
217 situation is to notify all other server processes that they
218 must terminate, by sending them <span class="systemitem">SIGQUIT</span>
219 signals. With this option, <span class="systemitem">SIGABRT</span>
220 will be sent instead, resulting in production of core dump files.
221 </p></dd><dt><span class="term"><code class="option">-v</code> <em class="replaceable"><code>protocol</code></em></span></dt><dd><p>
222 Specifies the version number of the frontend/backend protocol
223 to be used for a particular session. This option is for
225 </p></dd><dt><span class="term"><code class="option">-W</code> <em class="replaceable"><code>seconds</code></em></span></dt><dd><p>
226 A delay of this many seconds occurs when a new server process
227 is started, after it conducts the authentication procedure.
228 This is intended to give an opportunity to attach to the
229 server process with a debugger.
230 </p></dd></dl></div></div><div class="refsect2" id="id-1.9.5.16.6.5"><h3>Options for Single-User Mode</h3><a id="id-1.9.5.16.6.5.2" class="indexterm"></a><p>
231 The following options only apply to the single-user mode
232 (see <a class="xref" href="app-postgres.html#APP-POSTGRES-SINGLE-USER" title="Single-User Mode">Single-User Mode</a> below).
233 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--single</code></span></dt><dd><p>
234 Selects the single-user mode. This must be the first argument
236 </p></dd><dt><span class="term"><em class="replaceable"><code>database</code></em></span></dt><dd><p>
237 Specifies the name of the database to be accessed. This must be
238 the last argument on the command line. If it is
239 omitted it defaults to the user name.
240 </p></dd><dt><span class="term"><code class="option">-E</code></span></dt><dd><p>
241 Echo all commands to standard output before executing them.
242 </p></dd><dt><span class="term"><code class="option">-j</code></span></dt><dd><p>
243 Use semicolon followed by two newlines, rather than just newline,
244 as the command entry terminator.
245 </p></dd><dt><span class="term"><code class="option">-r</code> <em class="replaceable"><code>filename</code></em></span></dt><dd><p>
246 Send all server log output to <em class="replaceable"><code>filename</code></em>. This option is only
247 honored when supplied as a command-line option.
248 </p></dd></dl></div></div></div><div class="refsect1" id="id-1.9.5.16.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGCLIENTENCODING</code></span></dt><dd><p>
249 Default character encoding used by clients. (The clients can
250 override this individually.) This value can also be set in the
252 </p></dd><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
253 Default data directory location
254 </p></dd><dt><span class="term"><code class="envar">PGDATESTYLE</code></span></dt><dd><p>
255 Default value of the <a class="xref" href="runtime-config-client.html#GUC-DATESTYLE">DateStyle</a> run-time
256 parameter. (The use of this environment variable is deprecated.)
257 </p></dd><dt><span class="term"><code class="envar">PGPORT</code></span></dt><dd><p>
258 Default port number (preferably set in the configuration file)
259 </p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.16.8"><h2>Diagnostics</h2><p>
260 A failure message mentioning <code class="literal">semget</code> or
261 <code class="literal">shmget</code> probably indicates you need to configure your
262 kernel to provide adequate shared memory and semaphores. For more
263 discussion see <a class="xref" href="kernel-resources.html" title="18.4. Managing Kernel Resources">Section 18.4</a>. You might be able
264 to postpone reconfiguring your kernel by decreasing <a class="xref" href="runtime-config-resource.html#GUC-SHARED-BUFFERS">shared_buffers</a> to reduce the shared memory
265 consumption of <span class="productname">PostgreSQL</span>, and/or by reducing
266 <a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a> to reduce the semaphore
269 A failure message suggesting that another server is already running
270 should be checked carefully, for example by using the command
271 </p><pre class="screen">
272 <code class="prompt">$</code> <strong class="userinput"><code>ps ax | grep postgres</code></strong>
275 </p><pre class="screen">
276 <code class="prompt">$</code> <strong class="userinput"><code>ps -ef | grep postgres</code></strong>
278 depending on your system. If you are certain that no conflicting
279 server is running, you can remove the lock file mentioned in the
280 message and try again.
282 A failure message indicating inability to bind to a port might
283 indicate that that port is already in use by some
284 non-<span class="productname">PostgreSQL</span> process. You might also
285 get this error if you terminate <code class="command">postgres</code>
286 and immediately restart it using the same port; in this case, you
287 must simply wait a few seconds until the operating system closes
288 the port before trying again. Finally, you might get this error if
289 you specify a port number that your operating system considers to
290 be reserved. For example, many versions of Unix consider port
291 numbers under 1024 to be <span class="quote">“<span class="quote">trusted</span>”</span> and only permit
292 the Unix superuser to access them.
293 </p></div><div class="refsect1" id="id-1.9.5.16.9"><h2>Notes</h2><p>
294 The utility command <a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a> can be used to
295 start and shut down the <code class="command">postgres</code> server
296 safely and comfortably.
298 If at all possible, <span class="emphasis"><em>do not</em></span> use
299 <code class="literal">SIGKILL</code> to kill the main
300 <code class="command">postgres</code> server. Doing so will prevent
301 <code class="command">postgres</code> from freeing the system
302 resources (e.g., shared memory and semaphores) that it holds before
303 terminating. This might cause problems for starting a fresh
304 <code class="command">postgres</code> run.
306 To terminate the <code class="command">postgres</code> server normally, the
307 signals <code class="literal">SIGTERM</code>, <code class="literal">SIGINT</code>, or
308 <code class="literal">SIGQUIT</code> can be used. The first will wait for
309 all clients to terminate before quitting, the second will
310 forcefully disconnect all clients, and the third will quit
311 immediately without proper shutdown, resulting in a recovery run
314 The <code class="literal">SIGHUP</code> signal will reload
315 the server configuration files. It is also possible to send
316 <code class="literal">SIGHUP</code> to an individual server process, but that
317 is usually not sensible.
319 To cancel a running query, send the <code class="literal">SIGINT</code> signal
320 to the process running that command. To terminate a backend process
321 cleanly, send <code class="literal">SIGTERM</code> to that process. See
322 also <code class="function">pg_cancel_backend</code> and <code class="function">pg_terminate_backend</code>
323 in <a class="xref" href="functions-admin.html#FUNCTIONS-ADMIN-SIGNAL" title="9.28.2. Server Signaling Functions">Section 9.28.2</a> for the SQL-callable equivalents
324 of these two actions.
326 The <code class="command">postgres</code> server uses <code class="literal">SIGQUIT</code>
327 to tell subordinate server processes to terminate without normal
329 This signal <span class="emphasis"><em>should not</em></span> be used by users. It
330 is also unwise to send <code class="literal">SIGKILL</code> to a server
331 process — the main <code class="command">postgres</code> process will
332 interpret this as a crash and will force all the sibling processes
333 to quit as part of its standard crash-recovery procedure.
334 </p></div><div class="refsect1" id="APP-POSTGRES-BUGS"><h2>Bugs</h2><p>
335 The <code class="option">--</code> options will not work on <span class="systemitem">FreeBSD</span> or <span class="systemitem">OpenBSD</span>.
336 Use <code class="option">-c</code> instead. This is a bug in the affected operating
337 systems; a future release of <span class="productname">PostgreSQL</span>
338 will provide a workaround if this is not fixed.
339 </p></div><div class="refsect1" id="APP-POSTGRES-SINGLE-USER"><h2>Single-User Mode</h2><p>
340 To start a single-user mode server, use a command like
341 </p><pre class="screen">
342 <strong class="userinput"><code>postgres --single -D /usr/local/pgsql/data <em class="replaceable"><code>other-options</code></em> my_database</code></strong>
344 Provide the correct path to the database directory with <code class="option">-D</code>, or
345 make sure that the environment variable <code class="envar">PGDATA</code> is set.
346 Also specify the name of the particular database you want to work in.
348 Normally, the single-user mode server treats newline as the command
349 entry terminator; there is no intelligence about semicolons,
350 as there is in <span class="application">psql</span>. To continue a command
351 across multiple lines, you must type backslash just before each
352 newline except the last one. The backslash and adjacent newline are
353 both dropped from the input command. Note that this will happen even
354 when within a string literal or comment.
356 But if you use the <code class="option">-j</code> command line switch, a single newline
357 does not terminate command entry; instead, the sequence
358 semicolon-newline-newline does. That is, type a semicolon immediately
359 followed by a completely empty line. Backslash-newline is not
360 treated specially in this mode. Again, there is no intelligence about
361 such a sequence appearing within a string literal or comment.
363 In either input mode, if you type a semicolon that is not just before or
364 part of a command entry terminator, it is considered a command separator.
365 When you do type a command entry terminator, the multiple statements
366 you've entered will be executed as a single transaction.
368 To quit the session, type <acronym class="acronym">EOF</acronym>
369 (<span class="keycap"><strong>Control</strong></span>+<span class="keycap"><strong>D</strong></span>, usually).
370 If you've entered any text since the last command entry terminator,
371 then <acronym class="acronym">EOF</acronym> will be taken as a command entry terminator,
372 and another <acronym class="acronym">EOF</acronym> will be needed to exit.
374 Note that the single-user mode server does not provide sophisticated
375 line-editing features (no command history, for example).
376 Single-user mode also does not do any background processing, such as
377 automatic checkpoints or replication.
378 </p></div><div class="refsect1" id="APP-POSTGRES-EXAMPLES"><h2>Examples</h2><p>
379 To start <code class="command">postgres</code> in the background
380 using default values, type:
382 </p><pre class="screen">
383 <code class="prompt">$</code> <strong class="userinput"><code>nohup postgres >logfile 2>&1 </dev/null &</code></strong>
386 To start <code class="command">postgres</code> with a specific
388 </p><pre class="screen">
389 <code class="prompt">$</code> <strong class="userinput"><code>postgres -p 1234</code></strong>
391 To connect to this server using <span class="application">psql</span>, specify this port with the -p option:
392 </p><pre class="screen">
393 <code class="prompt">$</code> <strong class="userinput"><code>psql -p 1234</code></strong>
395 or set the environment variable <code class="envar">PGPORT</code>:
396 </p><pre class="screen">
397 <code class="prompt">$</code> <strong class="userinput"><code>export PGPORT=1234</code></strong>
398 <code class="prompt">$</code> <strong class="userinput"><code>psql</code></strong>
401 Named run-time parameters can be set in either of these styles:
402 </p><pre class="screen">
403 <code class="prompt">$</code> <strong class="userinput"><code>postgres -c work_mem=1234</code></strong>
404 <code class="prompt">$</code> <strong class="userinput"><code>postgres --work-mem=1234</code></strong>
406 Either form overrides whatever setting might exist for
407 <code class="varname">work_mem</code> in <code class="filename">postgresql.conf</code>. Notice that
408 underscores in parameter names can be written as either underscore
409 or dash on the command line. Except for short-term experiments,
410 it's probably better practice to edit the setting in
411 <code class="filename">postgresql.conf</code> than to rely on a command-line switch
413 </p></div><div class="refsect1" id="id-1.9.5.16.13"><h2>See Also</h2><p>
414 <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>,
415 <a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a>
416 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgwalsummary.html" title="pg_walsummary">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="internals.html" title="Part VII. Internals">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_walsummary</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Part VII. Internals</td></tr></table></div></body></html>