]> begriffs open source - ai-pg/blob - full-docs/html/app-initdb.html
Include links to all subsection html pages, with shorter paths too
[ai-pg] / full-docs / html / app-initdb.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>initdb</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="reference-server.html" title="PostgreSQL Server Applications" /><link rel="next" href="pgarchivecleanup.html" title="pg_archivecleanup" /></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">initdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="reference-server.html" title="PostgreSQL Server Applications">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="pgarchivecleanup.html" title="pg_archivecleanup">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-INITDB"><div class="titlepage"></div><a id="id-1.9.5.3.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">initdb</span></span></h2><p>initdb — create a new <span class="productname">PostgreSQL</span> database cluster</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.3.4.1"><code class="command">initdb</code> [<em class="replaceable"><code>option</code></em>...]  [ <code class="option">--pgdata</code>  |   <code class="option">-D</code> ]<em class="replaceable"><code> directory</code></em> </p></div></div><div class="refsect1" id="R1-APP-INITDB-1"><h2>Description</h2><p>
3    <code class="command">initdb</code> creates a new
4    <span class="productname">PostgreSQL</span> <a class="glossterm" href="glossary.html#GLOSSARY-DB-CLUSTER"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-DB-CLUSTER" title="Database cluster">database cluster</a></em></a>.
5   </p><p>
6    Creating a database cluster consists of creating the
7    <a class="glossterm" href="glossary.html#GLOSSARY-DATA-DIRECTORY"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-DATA-DIRECTORY" title="Data directory">directories</a></em></a> in
8    which the cluster data will live, generating the shared catalog
9    tables (tables that belong to the whole cluster rather than to any
10    particular database), and creating the <code class="literal">postgres</code>,
11    <code class="literal">template1</code>, and <code class="literal">template0</code> databases.
12    The <code class="literal">postgres</code> database is a default database meant
13    for use by users, utilities and third party applications.
14    <code class="literal">template1</code> and <code class="literal">template0</code> are
15    meant as source databases to be copied by later <code class="command">CREATE
16    DATABASE</code> commands.  <code class="literal">template0</code> should never
17    be modified, but you can add objects to <code class="literal">template1</code>,
18    which by default will be copied into databases created later.  See
19    <a class="xref" href="manage-ag-templatedbs.html" title="22.3. Template Databases">Section 22.3</a> for more details.
20   </p><p>
21    Although <code class="command">initdb</code> will attempt to create the
22    specified data directory, it might not have permission if the parent
23    directory of the desired data directory is root-owned. To initialize
24    in such a setup, create an empty data directory as root, then use
25    <code class="command">chown</code> to assign ownership of that directory to the
26    database user account, then <code class="command">su</code> to become the
27    database user to run <code class="command">initdb</code>.
28   </p><p>
29    <code class="command">initdb</code> must be run as the user that will own the
30    server process, because the server needs to have access to the
31    files and directories that <code class="command">initdb</code> creates.
32    Since the server cannot be run as root, you must not run
33    <code class="command">initdb</code> as root either.  (It will in fact refuse
34    to do so.)
35   </p><p>
36     For security reasons the new cluster created by <code class="command">initdb</code>
37     will only be accessible by the cluster owner by default.  The
38     <code class="option">--allow-group-access</code> option allows any user in the same
39     group as the cluster owner to read files in the cluster.  This is useful
40     for performing backups as a non-privileged user.
41   </p><p>
42    <code class="command">initdb</code> initializes the database cluster's default locale
43    and character set encoding. These can also be set separately for each
44    database when it is created. <code class="command">initdb</code> determines those
45    settings for the template databases, which will serve as the default for
46    all other databases.
47   </p><p>
48    By default, <code class="command">initdb</code> uses the locale provider
49    <code class="literal">libc</code> (see <a class="xref" href="locale.html#LOCALE-PROVIDERS" title="23.1.4. Locale Providers">Section 23.1.4</a>). The
50    <code class="literal">libc</code> locale provider takes the locale settings from the
51    environment, and determines the encoding from the locale settings.
52   </p><p>
53    To choose a different locale for the cluster, use the option
54    <code class="option">--locale</code>.  There are also individual options
55    <code class="option">--lc-*</code> and <code class="option">--icu-locale</code> (see below) to
56    set values for the individual locale categories.  Note that inconsistent
57    settings for different locale categories can give nonsensical results, so
58    this should be used with care.
59   </p><p>
60    Alternatively, <code class="command">initdb</code> can use the ICU library to provide
61    locale services by specifying <code class="literal">--locale-provider=icu</code>. The
62    server must be built with ICU support. To choose the specific ICU locale ID
63    to apply, use the option <code class="option">--icu-locale</code>.  Note that for
64    implementation reasons and to support legacy code,
65    <code class="command">initdb</code> will still select and initialize libc locale
66    settings when the ICU locale provider is used.
67   </p><p>
68    When <code class="command">initdb</code> runs, it will print out the locale settings
69    it has chosen.  If you have complex requirements or specified multiple
70    options, it is advisable to check that the result matches what was
71    intended.
72   </p><p>
73    More details about locale settings can be found in <a class="xref" href="locale.html" title="23.1. Locale Support">Section 23.1</a>.
74   </p><p>
75    To alter the default encoding, use the <code class="option">--encoding</code>.
76    More details can be found in <a class="xref" href="multibyte.html" title="23.3. Character Set Support">Section 23.3</a>.
77   </p></div><div class="refsect1" id="id-1.9.5.3.6"><h2>Options</h2><p>
78     </p><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-OPTION-AUTH"><span class="term"><code class="option">-A <em class="replaceable"><code>authmethod</code></em></code><br /></span><span class="term"><code class="option">--auth=<em class="replaceable"><code>authmethod</code></em></code></span> <a href="#APP-INITDB-OPTION-AUTH" class="id_link">#</a></dt><dd><p>
79         This option specifies the default authentication method for local
80         users used in <code class="filename">pg_hba.conf</code> (<code class="literal">host</code>
81         and <code class="literal">local</code> lines).  See <a class="xref" href="auth-pg-hba-conf.html" title="20.1. The pg_hba.conf File">Section 20.1</a>
82         for an overview of valid values.
83        </p><p>
84         <code class="command">initdb</code> will
85         prepopulate <code class="filename">pg_hba.conf</code> entries using the
86         specified authentication method for non-replication as well as
87         replication connections.
88        </p><p>
89         Do not use <code class="literal">trust</code> unless you trust all local users on your
90         system.  <code class="literal">trust</code> is the default for ease of installation.
91        </p></dd><dt id="APP-INITDB-OPTION-AUTH-HOST"><span class="term"><code class="option">--auth-host=<em class="replaceable"><code>authmethod</code></em></code></span> <a href="#APP-INITDB-OPTION-AUTH-HOST" class="id_link">#</a></dt><dd><p>
92         This option specifies the authentication method for local users via
93         TCP/IP connections used in <code class="filename">pg_hba.conf</code>
94         (<code class="literal">host</code> lines).
95        </p></dd><dt id="APP-INITDB-OPTION-AUTH-LOCAL"><span class="term"><code class="option">--auth-local=<em class="replaceable"><code>authmethod</code></em></code></span> <a href="#APP-INITDB-OPTION-AUTH-LOCAL" class="id_link">#</a></dt><dd><p>
96         This option specifies the authentication method for local users via
97         Unix-domain socket connections used in <code class="filename">pg_hba.conf</code>
98         (<code class="literal">local</code> lines).
99        </p></dd><dt id="APP-INITDB-OPTION-PGDATA"><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span> <a href="#APP-INITDB-OPTION-PGDATA" class="id_link">#</a></dt><dd><p>
100         This option specifies the directory where the database cluster
101         should be stored. This is the only information required by
102         <code class="command">initdb</code>, but you can avoid writing it by
103         setting the <code class="envar">PGDATA</code> environment variable, which
104         can be convenient since the database server
105         (<code class="command">postgres</code>) can find the data
106         directory later by the same variable.
107        </p></dd><dt id="APP-INITDB-OPTION-ENCODING"><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span> <a href="#APP-INITDB-OPTION-ENCODING" class="id_link">#</a></dt><dd><p>
108         Selects the encoding of the template databases. This will also be the
109         default encoding of any database you create later, unless you override
110         it then. The character sets supported by the
111         <span class="productname">PostgreSQL</span> server are described in <a class="xref" href="multibyte.html#MULTIBYTE-CHARSET-SUPPORTED" title="23.3.1. Supported Character Sets">Section 23.3.1</a>.
112        </p><p>
113         By default, the template database encoding is derived from the
114         locale. If <a class="xref" href="app-initdb.html#APP-INITDB-OPTION-NO-LOCALE"><code class="option">--no-locale</code></a> is specified
115         (or equivalently, if the locale is <code class="literal">C</code> or
116         <code class="literal">POSIX</code>), then the default is <code class="literal">UTF8</code>
117         for the ICU provider and <code class="literal">SQL_ASCII</code> for the
118         <code class="literal">libc</code> provider.
119        </p></dd><dt id="APP-INITDB-ALLOW-GROUP-ACCESS"><span class="term"><code class="option">-g</code><br /></span><span class="term"><code class="option">--allow-group-access</code></span> <a href="#APP-INITDB-ALLOW-GROUP-ACCESS" class="id_link">#</a></dt><dd><p>
120         Allows users in the same group as the cluster owner to read all cluster
121         files created by <code class="command">initdb</code>.  This option is ignored
122         on <span class="productname">Windows</span> as it does not support
123         <acronym class="acronym">POSIX</acronym>-style group permissions.
124        </p></dd><dt id="APP-INITDB-ICU-LOCALE"><span class="term"><code class="option">--icu-locale=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-ICU-LOCALE" class="id_link">#</a></dt><dd><p>
125         Specifies the ICU locale when the ICU provider is used. Locale support
126         is described in <a class="xref" href="locale.html" title="23.1. Locale Support">Section 23.1</a>.
127        </p></dd><dt id="APP-INITDB-ICU-RULES"><span class="term"><code class="option">--icu-rules=<em class="replaceable"><code>rules</code></em></code></span> <a href="#APP-INITDB-ICU-RULES" class="id_link">#</a></dt><dd><p>
128         Specifies additional collation rules to customize the behavior of the
129         default collation.  This is supported for ICU only.
130        </p></dd><dt id="APP-INITDB-DATA-CHECKSUMS"><span class="term"><code class="option">-k</code><br /></span><span class="term"><code class="option">--data-checksums</code></span> <a href="#APP-INITDB-DATA-CHECKSUMS" class="id_link">#</a></dt><dd><p>
131         Use checksums on data pages to help detect corruption by the I/O
132         system that would otherwise be silent.  This is enabled by default;
133         use <a class="xref" href="app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS"><code class="option">--no-data-checksums</code></a> to disable
134         checksums.
135        </p><p>
136         Enabling checksums
137         might incur a small performance penalty. If set, checksums
138         are calculated for all objects, in all databases. All checksum
139         failures will be reported in the
140         <a class="link" href="monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW" title="27.2.17. pg_stat_database">
141         <code class="structname">pg_stat_database</code></a> view.
142         See <a class="xref" href="checksums.html" title="28.2. Data Checksums">Section 28.2</a> for details.
143        </p></dd><dt id="APP-INITDB-OPTION-LOCALE"><span class="term"><code class="option">--locale=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-OPTION-LOCALE" class="id_link">#</a></dt><dd><p>
144         Sets the default locale for the database cluster.  If this
145         option is not specified, the locale is inherited from the
146         environment that <code class="command">initdb</code> runs in. Locale
147         support is described in <a class="xref" href="locale.html" title="23.1. Locale Support">Section 23.1</a>.
148        </p><p>
149         If <code class="option">--locale-provider</code> is <code class="literal">builtin</code>,
150         <code class="option">--locale</code> or <code class="option">--builtin-locale</code> must be
151         specified and set to <code class="literal">C</code>, <code class="literal">C.UTF-8</code>
152         or <code class="literal">PG_UNICODE_FAST</code>.
153        </p></dd><dt id="APP-INITDB-OPTION-LC-COLLATE"><span class="term"><code class="option">--lc-collate=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-ctype=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-messages=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-monetary=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-numeric=<em class="replaceable"><code>locale</code></em></code><br /></span><span class="term"><code class="option">--lc-time=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-OPTION-LC-COLLATE" class="id_link">#</a></dt><dd><p>
154         Like <code class="option">--locale</code>, but only sets the locale in
155         the specified category.
156        </p></dd><dt id="APP-INITDB-OPTION-NO-LOCALE"><span class="term"><code class="option">--no-locale</code></span> <a href="#APP-INITDB-OPTION-NO-LOCALE" class="id_link">#</a></dt><dd><p>
157         Equivalent to <code class="option">--locale=C</code>.
158        </p></dd><dt id="APP-INITDB-BUILTIN-LOCALE"><span class="term"><code class="option">--builtin-locale=<em class="replaceable"><code>locale</code></em></code></span> <a href="#APP-INITDB-BUILTIN-LOCALE" class="id_link">#</a></dt><dd><p>
159         Specifies the locale name when the builtin provider is used. Locale support
160         is described in <a class="xref" href="locale.html" title="23.1. Locale Support">Section 23.1</a>.
161        </p></dd><dt id="APP-INITDB-OPTION-LOCALE-PROVIDER"><span class="term"><code class="option">--locale-provider={<code class="literal">builtin</code>|<code class="literal">libc</code>|<code class="literal">icu</code>}</code></span> <a href="#APP-INITDB-OPTION-LOCALE-PROVIDER" class="id_link">#</a></dt><dd><p>
162         This option sets the locale provider for databases created in the new
163         cluster.  It can be overridden in the <code class="command">CREATE
164         DATABASE</code> command when new databases are subsequently
165         created.  The default is <code class="literal">libc</code> (see <a class="xref" href="locale.html#LOCALE-PROVIDERS" title="23.1.4. Locale Providers">Section 23.1.4</a>).
166        </p></dd><dt id="APP-INITDB-NO-DATA-CHECKSUMS"><span class="term"><code class="option">--no-data-checksums</code></span> <a href="#APP-INITDB-NO-DATA-CHECKSUMS" class="id_link">#</a></dt><dd><p>
167         Do not enable data checksums.
168        </p></dd><dt id="APP-INITDB-OPTION-PWFILE"><span class="term"><code class="option">--pwfile=<em class="replaceable"><code>filename</code></em></code></span> <a href="#APP-INITDB-OPTION-PWFILE" class="id_link">#</a></dt><dd><p>
169         Makes <code class="command">initdb</code> read the bootstrap superuser's password
170         from a file.  The first line of the file is taken as the password.
171        </p></dd><dt id="APP-INITDB-OPTION-TEXT-SEARCH-CONFIG"><span class="term"><code class="option">-T <em class="replaceable"><code>config</code></em></code><br /></span><span class="term"><code class="option">--text-search-config=<em class="replaceable"><code>config</code></em></code></span> <a href="#APP-INITDB-OPTION-TEXT-SEARCH-CONFIG" class="id_link">#</a></dt><dd><p>
172         Sets the default text search configuration.
173         See <a class="xref" href="runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG">default_text_search_config</a> for further information.
174        </p></dd><dt id="APP-INITDB-OPTION-USERNAME"><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span> <a href="#APP-INITDB-OPTION-USERNAME" class="id_link">#</a></dt><dd><p>
175         Sets the user name of the
176         <a class="glossterm" href="glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER"><em class="glossterm"><a class="glossterm" href="glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER" title="Bootstrap superuser">bootstrap superuser</a></em></a>.
177         This defaults to the name of the operating-system user running
178         <code class="command">initdb</code>.
179        </p></dd><dt id="APP-INITDB-OPTION-PWPROMPT"><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--pwprompt</code></span> <a href="#APP-INITDB-OPTION-PWPROMPT" class="id_link">#</a></dt><dd><p>
180         Makes <code class="command">initdb</code> prompt for a password
181         to give the bootstrap superuser. If you don't plan on using password
182         authentication, this is not important.  Otherwise you won't be
183         able to use password authentication until you have a password
184         set up.
185        </p></dd><dt id="APP-INITDB-OPTION-WALDIR"><span class="term"><code class="option">-X <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--waldir=<em class="replaceable"><code>directory</code></em></code></span> <a href="#APP-INITDB-OPTION-WALDIR" class="id_link">#</a></dt><dd><p>
186         This option specifies the directory where the write-ahead log
187         should be stored.
188        </p></dd><dt id="APP-INITDB-OPTION-WAL-SEGSIZE"><span class="term"><code class="option">--wal-segsize=<em class="replaceable"><code>size</code></em></code></span> <a href="#APP-INITDB-OPTION-WAL-SEGSIZE" class="id_link">#</a></dt><dd><p>
189         Set the <em class="firstterm">WAL segment size</em>, in megabytes.  This
190         is the size of each individual file in the WAL log.  The default size
191         is 16 megabytes.  The value must be a power of 2 between 1 and 1024
192         (megabytes).  This option can only be set during initialization, and
193         cannot be changed later.
194        </p><p>
195         It may be useful to adjust this size to control the granularity of
196         WAL log shipping or archiving.  Also, in databases with a high volume
197         of WAL, the sheer number of WAL files per directory can become a
198         performance and management problem.  Increasing the WAL file size
199         will reduce the number of WAL files.
200        </p></dd></dl></div><p>
201    </p><p>
202     Other, less commonly used, options are also available:
203
204     </p><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-OPTION-SET"><span class="term"><code class="option">-c <em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code><br /></span><span class="term"><code class="option">--set <em class="replaceable"><code>name</code></em>=<em class="replaceable"><code>value</code></em></code></span> <a href="#APP-INITDB-OPTION-SET" class="id_link">#</a></dt><dd><p>
205         Forcibly set the server parameter <em class="replaceable"><code>name</code></em>
206         to <em class="replaceable"><code>value</code></em> during <code class="command">initdb</code>,
207         and also install that setting in the
208         generated <code class="filename">postgresql.conf</code> file,
209         so that it will apply during future server runs.
210         This option can be given more than once to set several parameters.
211         It is primarily useful when the environment is such that the server
212         will not start at all using the default parameters.
213        </p></dd><dt id="APP-INITDB-OPTION-DEBUG"><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--debug</code></span> <a href="#APP-INITDB-OPTION-DEBUG" class="id_link">#</a></dt><dd><p>
214         Print debugging output from the bootstrap backend and a few other
215         messages of lesser interest for the general public.
216         The bootstrap backend is the program <code class="command">initdb</code>
217         uses to create the catalog tables.  This option generates a tremendous
218         amount of extremely boring output.
219        </p></dd><dt id="APP-INITDB-OPTION-DISCARD-CACHES"><span class="term"><code class="option">--discard-caches</code></span> <a href="#APP-INITDB-OPTION-DISCARD-CACHES" class="id_link">#</a></dt><dd><p>
220         Run the bootstrap backend with the
221         <code class="literal">debug_discard_caches=1</code> option.
222         This takes a very long time and is only of use for deep debugging.
223        </p></dd><dt id="APP-INITDB-OPTION-L"><span class="term"><code class="option">-L <em class="replaceable"><code>directory</code></em></code></span> <a href="#APP-INITDB-OPTION-L" class="id_link">#</a></dt><dd><p>
224         Specifies where <code class="command">initdb</code> should find
225         its input files to initialize the database cluster.  This is
226         normally not necessary.  You will be told if you need to
227         specify their location explicitly.
228        </p></dd><dt id="APP-INITDB-OPTION-NO-CLEAN"><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-clean</code></span> <a href="#APP-INITDB-OPTION-NO-CLEAN" class="id_link">#</a></dt><dd><p>
229         By default, when <code class="command">initdb</code>
230         determines that an error prevented it from completely creating the database
231         cluster, it removes any files it might have created before discovering
232         that it cannot finish the job. This option inhibits tidying-up and is
233         thus useful for debugging.
234        </p></dd><dt id="APP-INITDB-OPTION-NO-SYNC"><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--no-sync</code></span> <a href="#APP-INITDB-OPTION-NO-SYNC" class="id_link">#</a></dt><dd><p>
235         By default, <code class="command">initdb</code> will wait for all files to be
236         written safely to disk.  This option causes <code class="command">initdb</code>
237         to return without waiting, which is faster, but means that a
238         subsequent operating system crash can leave the data directory
239         corrupt.  Generally, this option is useful for testing, but should not
240         be used when creating a production installation.
241        </p></dd><dt id="APP-INITDB-OPTION-NO-SYNC-DATA-FILES"><span class="term"><code class="option">--no-sync-data-files</code></span> <a href="#APP-INITDB-OPTION-NO-SYNC-DATA-FILES" class="id_link">#</a></dt><dd><p>
242         By default, <code class="command">initdb</code> safely writes all database files
243         to disk.  This option instructs <code class="command">initdb</code> to skip
244         synchronizing all files in the individual database directories, the
245         database directories themselves, and the tablespace directories, i.e.,
246         everything in the <code class="filename">base</code> subdirectory and any other
247         tablespace directories.  Other files, such as those in
248         <code class="literal">pg_wal</code> and <code class="literal">pg_xact</code>, will still be
249         synchronized unless the <code class="option">--no-sync</code> option is also
250         specified.
251        </p><p>
252         Note that if <code class="option">--no-sync-data-files</code> is used in
253         conjunction with <code class="option">--sync-method=syncfs</code>, some or all of
254         the aforementioned files and directories will be synchronized because
255         <code class="literal">syncfs</code> processes entire file systems.
256        </p><p>
257         This option is primarily intended for internal use by tools that
258         separately ensure the skipped files are synchronized to disk.
259        </p></dd><dt id="APP-INITDB-OPTION-NO-INSTRUCTIONS"><span class="term"><code class="option">--no-instructions</code></span> <a href="#APP-INITDB-OPTION-NO-INSTRUCTIONS" class="id_link">#</a></dt><dd><p>
260         By default, <code class="command">initdb</code> will write instructions for how
261         to start the cluster at the end of its output. This option causes
262         those instructions to be left out. This is primarily intended for use
263         by tools that wrap <code class="command">initdb</code> in platform-specific
264         behavior, where those instructions are likely to be incorrect.
265        </p></dd><dt id="APP-INITDB-OPTION-SHOW"><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--show</code></span> <a href="#APP-INITDB-OPTION-SHOW" class="id_link">#</a></dt><dd><p>
266         Show internal settings and exit, without doing anything else.  This
267         can be used to debug the <span class="application">initdb</span>
268         installation.
269        </p></dd><dt id="APP-INITDB-OPTION-SYNC-METHOD"><span class="term"><code class="option">--sync-method=<em class="replaceable"><code>method</code></em></code></span> <a href="#APP-INITDB-OPTION-SYNC-METHOD" class="id_link">#</a></dt><dd><p>
270         When set to <code class="literal">fsync</code>, which is the default,
271         <code class="command">initdb</code> will recursively open and synchronize all
272         files in the data directory.  The search for files will follow symbolic
273         links for the WAL directory and each configured tablespace.
274        </p><p>
275         On Linux, <code class="literal">syncfs</code> may be used instead to ask the
276         operating system to synchronize the whole file systems that contain the
277         data directory, the WAL files, and each tablespace.  See
278         <a class="xref" href="runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD">recovery_init_sync_method</a> for information about
279         the caveats to be aware of when using <code class="literal">syncfs</code>.
280        </p><p>
281         This option has no effect when <code class="option">--no-sync</code> is used.
282        </p></dd><dt id="APP-INITDB-OPTION-SYNC-ONLY"><span class="term"><code class="option">-S</code><br /></span><span class="term"><code class="option">--sync-only</code></span> <a href="#APP-INITDB-OPTION-SYNC-ONLY" class="id_link">#</a></dt><dd><p>
283         Safely write all database files to disk and exit.  This does not
284         perform any of the normal <span class="application">initdb</span> operations.
285         Generally, this option is useful for ensuring reliable recovery after
286         changing <a class="xref" href="runtime-config-wal.html#GUC-FSYNC">fsync</a> from <code class="literal">off</code> to
287         <code class="literal">on</code>.
288        </p></dd></dl></div><p>
289    </p><p>
290     Other options:
291
292     </p><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-OPTION-VERSION"><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span> <a href="#APP-INITDB-OPTION-VERSION" class="id_link">#</a></dt><dd><p>
293        Print the <span class="application">initdb</span> version and exit.
294        </p></dd><dt id="APP-INITDB-OPTION-HELP"><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span> <a href="#APP-INITDB-OPTION-HELP" class="id_link">#</a></dt><dd><p>
295        Show help about <span class="application">initdb</span> command line
296        arguments, and exit.
297        </p></dd></dl></div><p>
298    </p></div><div class="refsect1" id="id-1.9.5.3.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt id="APP-INITDB-ENVIRONMENT-PGDATA"><span class="term"><code class="envar">PGDATA</code></span> <a href="#APP-INITDB-ENVIRONMENT-PGDATA" class="id_link">#</a></dt><dd><p>
299       Specifies the directory where the database cluster is to be
300       stored; can be overridden using the <code class="option">-D</code> option.
301      </p></dd><dt id="APP-INITDB-ENVIRONMENT-PG-COLOR"><span class="term"><code class="envar">PG_COLOR</code></span> <a href="#APP-INITDB-ENVIRONMENT-PG-COLOR" class="id_link">#</a></dt><dd><p>
302       Specifies whether to use color in diagnostic messages. Possible values
303       are <code class="literal">always</code>, <code class="literal">auto</code> and
304       <code class="literal">never</code>.
305      </p></dd><dt id="APP-INITDB-ENVIRONMENT-TZ"><span class="term"><code class="envar">TZ</code></span> <a href="#APP-INITDB-ENVIRONMENT-TZ" class="id_link">#</a></dt><dd><p>
306       Specifies the default time zone of the created database cluster.  The
307       value should be a full time zone name
308       (see <a class="xref" href="datatype-datetime.html#DATATYPE-TIMEZONES" title="8.5.3. Time Zones">Section 8.5.3</a>).
309      </p></dd></dl></div></div><div class="refsect1" id="id-1.9.5.3.8"><h2>Notes</h2><p>
310    <code class="command">initdb</code> can also be invoked via
311    <code class="command">pg_ctl initdb</code>.
312   </p></div><div class="refsect1" id="id-1.9.5.3.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a>, <a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a>, <a class="xref" href="auth-pg-hba-conf.html" title="20.1. The pg_hba.conf File">Section 20.1</a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="reference-server.html" title="PostgreSQL Server Applications">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="pgarchivecleanup.html" title="pg_archivecleanup">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PostgreSQL Server Applications </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"> <span class="application">pg_archivecleanup</span></td></tr></table></div></body></html>