Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
app-postgres.html416 linesDownload Raw Back to html
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="pgwaldump.html" title="pg_waldump" /><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="pgwaldump.html" title="pg_waldump">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 16.3 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.14.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.14.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.14.5"><h2>Description</h2><p>3   <code class="command">postgres</code> is the4   <span class="productname">PostgreSQL</span> database server.  In order5   for a client application to access a database it connects (over a6   network or locally) to a running <code class="command">postgres</code> instance.7   The <code class="command">postgres</code> instance then starts a separate server8   process to handle the connection.9  </p><p>10   One <code class="command">postgres</code> instance always manages the data of11   exactly one database cluster.  A database cluster is a collection12   of databases that is stored at a common file system location (the13   <span class="quote">“<span class="quote">data area</span>”</span>).  More than one14   <code class="command">postgres</code> instance can run on a system at one15   time, so long as they use different data areas and different16   communication ports (see below).  When17   <code class="command">postgres</code> starts it needs to know the location18   of the data area.  The location must be specified by the19   <code class="option">-D</code> option or the <code class="envar">PGDATA</code> environment20   variable; there is no default.  Typically, <code class="option">-D</code> or21   <code class="envar">PGDATA</code> points directly to the data area directory22   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 are23   discussed in <a class="xref" href="runtime-config-file-locations.html" title="20.2. File Locations">Section 20.2</a>.24  </p><p>25   By default <code class="command">postgres</code> starts in the26   foreground and prints log messages to the standard error stream.  In27   practical applications <code class="command">postgres</code>28   should be started as a background process, perhaps at boot time.29  </p><p>30   The <code class="command">postgres</code> command can also be called in31   single-user mode.  The primary use for this mode is during32   bootstrapping by <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle"><span class="application">initdb</span></span></a>.  Sometimes it is used33   for debugging or disaster recovery;  note that running a single-user34   server is not truly suitable for debugging the server, since no35   realistic interprocess communication and locking will happen.36   When invoked in single-user37   mode from the shell, the user can enter queries and the results38   will be printed to the screen, but in a form that is more useful39   for developers than end users.  In the single-user mode,40   the session user will be set to the user with ID 1, and implicit41   superuser powers are granted to this user.42   This user does not actually have to exist, so the single-user mode43   can be used to manually recover from certain44   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-line47    arguments.  For a detailed discussion of the options consult <a class="xref" href="runtime-config.html" title="Chapter 20. Server Configuration">Chapter 20</a>.  You can save typing most of these48    options by setting up a configuration file.  Some (safe) options49    can also be set from the connecting client in an50    application-dependent way to apply only for that session.  For51    example, if the environment variable <code class="envar">PGOPTIONS</code> is52    set, then <span class="application">libpq</span>-based clients will pass that53    string to the server, which will interpret it as54    <code class="command">postgres</code> command-line options.55   </p><div class="refsect2" id="id-1.9.5.14.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 server57        processes.  The default value of this parameter is chosen58        automatically by <span class="application">initdb</span>.59        Specifying this option is equivalent to setting the60        <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 parameters63        supported by <span class="productname">PostgreSQL</span> are64        described in <a class="xref" href="runtime-config.html" title="Chapter 20. Server Configuration">Chapter 20</a>. Most of the65        other command line options are in fact short forms of such a66        parameter assignment.  <code class="option">-c</code> can appear multiple times67        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.)  This71        returns values from72        <code class="filename">postgresql.conf</code>, modified by any parameters73        supplied in this invocation.  It does not reflect parameters74        supplied when the cluster was started.75       </p><p>76        This can be used on a running server for most parameters.  However,77        the server must be shut down for some runtime-computed parameters78        (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>, and80        <a class="xref" href="runtime-config-preset.html#GUC-WAL-SEGMENT-SIZE">wal_segment_size</a>).81       </p><p>82        This option is meant for other programs that interact with a server83        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 configuration84        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 more87        debugging output is written to the server log.  Values are88        from 1 to 5.  It is also possible to pass <code class="literal">-d89        0</code> for a specific session, which will prevent the90        server log level of the parent <code class="command">postgres</code> process from being91        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 database94        configuration files.  See95        <a class="xref" href="runtime-config-file-locations.html" title="20.2. File Locations">Section 20.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 is98        <code class="literal">DMY</code> ordering of input date fields.  This also causes99        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 improved103        performance, at the risk of data corruption in the event of a104        system crash.  Specifying this option is equivalent to105        disabling the <a class="xref" href="runtime-config-wal.html#GUC-FSYNC">fsync</a> configuration106        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 which109        <code class="command">postgres</code> is to listen for TCP/IP110        connections from client applications.  The value can also be a111        comma-separated list of addresses, or <code class="literal">*</code> to specify112        listening on all available interfaces.  An empty value113        specifies not listening on any IP addresses, in which case114        only Unix-domain sockets can be used to connect to the115        server.  Defaults to listening only on116        <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 are121        accepted.  This option is equivalent to setting122        <code class="varname">listen_addresses</code> to <code class="literal">*</code> in123        <code class="filename">postgresql.conf</code> or via <code class="option">-h</code>.124       </p><p>125        This option is deprecated since it does not allow access to the126        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 which130        <code class="command">postgres</code> is to listen for131        connections from client applications.  The value can also be a132        comma-separated list of directories.  An empty value133        specifies not listening on any Unix-domain sockets, in which case134        only TCP/IP sockets can be used to connect to the server.135        The default value is normally136        <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 with141        support for <acronym class="acronym">SSL</acronym> for this option to be142        available. For more information on using <acronym class="acronym">SSL</acronym>,143        refer to <a class="xref" href="ssl-tcp.html" title="19.9. Secure TCP/IP Connections with SSL">Section 19.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 this146        server will accept.  The default value of this parameter is chosen147        automatically by <span class="application">initdb</span>.148        Specifying this option is equivalent to setting the149        <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 file152        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> environment155        variable, or if <code class="envar">PGPORT</code> is not set, then156        defaults to the value established during compilation (normally157        5432).  If you specify a port other than the default port,158        then all client applications must specify the same port using159        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 of163        buffers.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 and166        hash tables before resorting to temporary disk files.  See the167        description of the <code class="varname">work_mem</code> configuration168        parameter in <a class="xref" href="runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY" title="20.4.1. Memory">Section 20.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 of173        <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 line180        arguments, and exit.181       </p></dd></dl></div></div><div class="refsect2" id="id-1.9.5.14.6.4"><h3>Semi-Internal Options</h3><p>182     The options described here are used183     mainly for debugging purposes, and in some cases to assist with184     recovery of severely damaged databases. There should be no reason185     to use them in a production database setup.  They are listed186     here only for use by <span class="productname">PostgreSQL</span>187     system developers.  Furthermore, these options might188     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 scans195        respectively, while196        <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.198       </p><p>199        Neither sequential scans nor nested-loop joins can be disabled200        completely; the <code class="literal">-fs</code> and201        <code class="literal">-fn</code> options simply discourage the optimizer202        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 is205        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 update208        the indexes when modifying the tables.  This is useful when209        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 the212        major system modules.  This option cannot be used together213        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 server216        process to die abnormally.  The ordinary strategy in this217        situation is to notify all other server processes that they218        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 protocol223        to be used for a particular session.  This option is for224        internal use only.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 process227        is started, after it conducts the authentication procedure.228        This is intended to give an opportunity to attach to the229        server process with a debugger.230       </p></dd></dl></div></div><div class="refsect2" id="id-1.9.5.14.6.5"><h3>Options for Single-User Mode</h3><a id="id-1.9.5.14.6.5.2" class="indexterm"></a><p>231     The following options only apply to the single-user mode232     (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 argument235        on the command line.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 be238        the last argument on the command line.  If it is239        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 only247        honored when supplied as a command-line option.248       </p></dd></dl></div></div></div><div class="refsect1" id="id-1.9.5.14.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 can250      override this individually.)  This value can also be set in the251      configuration file.252     </p></dd><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>253      Default data directory location254     </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-time256      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.14.8"><h2>Diagnostics</h2><p>260    A failure message mentioning <code class="literal">semget</code> or261    <code class="literal">shmget</code> probably indicates you need to configure your262    kernel to provide adequate shared memory and semaphores.  For more263    discussion see <a class="xref" href="kernel-resources.html" title="19.4. Managing Kernel Resources">Section 19.4</a>.  You might be able264    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 memory265    consumption of <span class="productname">PostgreSQL</span>, and/or by reducing266    <a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a> to reduce the semaphore267    consumption.268   </p><p>269    A failure message suggesting that another server is already running270    should be checked carefully, for example by using the command271</p><pre class="screen">272<code class="prompt">$</code> <strong class="userinput"><code>ps ax | grep postgres</code></strong>273</pre><p>274        or275</p><pre class="screen">276<code class="prompt">$</code> <strong class="userinput"><code>ps -ef | grep postgres</code></strong>277</pre><p>278    depending on your system.  If you are certain that no conflicting279    server is running, you can remove the lock file mentioned in the280    message and try again.281   </p><p>282    A failure message indicating inability to bind to a port might283    indicate that that port is already in use by some284    non-<span class="productname">PostgreSQL</span> process.  You might also285    get this error if you terminate <code class="command">postgres</code>286    and immediately restart it using the same port; in this case, you287    must simply wait a few seconds until the operating system closes288    the port before trying again.  Finally, you might get this error if289    you specify a port number that your operating system considers to290    be reserved.  For example, many versions of Unix consider port291    numbers under 1024 to be <span class="quote">“<span class="quote">trusted</span>”</span> and only permit292    the Unix superuser to access them.293   </p></div><div class="refsect1" id="id-1.9.5.14.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 to295   start and shut down the <code class="command">postgres</code> server296   safely and comfortably.297  </p><p>298   If at all possible, <span class="emphasis"><em>do not</em></span> use299   <code class="literal">SIGKILL</code> to kill the main300   <code class="command">postgres</code> server.  Doing so will prevent301   <code class="command">postgres</code> from freeing the system302   resources (e.g., shared memory and semaphores) that it holds before303   terminating.  This might cause problems for starting a fresh304   <code class="command">postgres</code> run.305  </p><p>306   To terminate the <code class="command">postgres</code> server normally, the307   signals <code class="literal">SIGTERM</code>, <code class="literal">SIGINT</code>, or308   <code class="literal">SIGQUIT</code> can be used.  The first will wait for309   all clients to terminate before quitting, the second will310   forcefully disconnect all clients, and the third will quit311   immediately without proper shutdown, resulting in a recovery run312   during restart.313  </p><p>314   The <code class="literal">SIGHUP</code> signal will reload315   the server configuration files.  It is also possible to send316   <code class="literal">SIGHUP</code> to an individual server process, but that317   is usually not sensible.318  </p><p>319   To cancel a running query, send the <code class="literal">SIGINT</code> signal320   to the process running that command. To terminate a backend process321   cleanly, send <code class="literal">SIGTERM</code> to that process. See322   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.27.2. Server Signaling Functions">Section 9.27.2</a> for the SQL-callable equivalents324   of these two actions.325  </p><p>326   The <code class="command">postgres</code> server uses <code class="literal">SIGQUIT</code>327   to tell subordinate server processes to terminate without normal328   cleanup.329   This signal <span class="emphasis"><em>should not</em></span> be used by users.  It330   is also unwise to send <code class="literal">SIGKILL</code> to a server331   process — the main <code class="command">postgres</code> process will332   interpret this as a crash and will force all the sibling processes333   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 operating337   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 like341</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>343</pre><p>344    Provide the correct path to the database directory with <code class="option">-D</code>, or345    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.347   </p><p>348    Normally, the single-user mode server treats newline as the command349    entry terminator; there is no intelligence about semicolons,350    as there is in <span class="application">psql</span>.  To continue a command351    across multiple lines, you must type backslash just before each352    newline except the last one.  The backslash and adjacent newline are353    both dropped from the input command.  Note that this will happen even354    when within a string literal or comment.355   </p><p>356    But if you use the <code class="option">-j</code> command line switch, a single newline357    does not terminate command entry; instead, the sequence358    semicolon-newline-newline does.  That is, type a semicolon immediately359    followed by a completely empty line.  Backslash-newline is not360    treated specially in this mode.  Again, there is no intelligence about361    such a sequence appearing within a string literal or comment.362   </p><p>363    In either input mode, if you type a semicolon that is not just before or364    part of a command entry terminator, it is considered a command separator.365    When you do type a command entry terminator, the multiple statements366    you've entered will be executed as a single transaction.367   </p><p>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.373   </p><p>374    Note that the single-user mode server does not provide sophisticated375    line-editing features (no command history, for example).376    Single-user mode also does not do any background processing, such as377    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 background380   using default values, type:381 382</p><pre class="screen">383<code class="prompt">$</code> <strong class="userinput"><code>nohup postgres &gt;logfile 2&gt;&amp;1 &lt;/dev/null &amp;</code></strong>384</pre><p>385  </p><p>386   To start <code class="command">postgres</code> with a specific387   port, e.g., 1234:388</p><pre class="screen">389<code class="prompt">$</code> <strong class="userinput"><code>postgres -p 1234</code></strong>390</pre><p>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>394</pre><p>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>399</pre><p>400  </p><p>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>405</pre><p>406   Either form overrides whatever setting might exist for407   <code class="varname">work_mem</code> in <code class="filename">postgresql.conf</code>.  Notice that408   underscores in parameter names can be written as either underscore409   or dash on the command line.  Except for short-term experiments,410   it's probably better practice to edit the setting in411   <code class="filename">postgresql.conf</code> than to rely on a command-line switch412   to set a parameter.413  </p></div><div class="refsect1" id="id-1.9.5.14.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="pgwaldump.html" title="pg_waldump">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_waldump</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Part VII. Internals</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai