| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/initdb.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="app-initdb"> |
| 7 |
<indexterm zone="app-initdb"> |
| 8 |
<primary>initdb</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle><application>initdb</application></refentrytitle> |
| 13 |
<manvolnum>1</manvolnum> |
| 14 |
<refmiscinfo>Application</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>initdb</refname> |
| 19 |
<refpurpose>create a new <productname>PostgreSQL</productname> database cluster</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<cmdsynopsis> |
| 24 |
<command>initdb</command> |
| 25 |
<arg rep="repeat"><replaceable>option</replaceable></arg> |
| 26 |
<group choice="plain"> |
| 27 |
<group choice="opt"> |
| 28 |
<arg choice="plain"><option>--pgdata</option></arg> |
| 29 |
<arg choice="plain"><option>-D</option></arg> |
| 30 |
</group> |
| 31 |
<replaceable> directory</replaceable> |
| 32 |
</group> |
| 33 |
</cmdsynopsis> |
| 34 |
</refsynopsisdiv> |
| 35 |
|
| 36 |
<refsect1 id="r1-app-initdb-1"> |
| 37 |
<title>Description</title> |
| 38 |
<para> |
| 39 |
<command>initdb</command> creates a new |
| 40 |
<productname>PostgreSQL</productname> <glossterm linkend="glossary-db-cluster">database cluster</glossterm>. |
| 41 |
</para> |
| 42 |
|
| 43 |
<para> |
| 44 |
Creating a database cluster consists of creating the |
| 45 |
<glossterm linkend="glossary-data-directory">directories</glossterm> in |
| 46 |
which the cluster data will live, generating the shared catalog |
| 47 |
tables (tables that belong to the whole cluster rather than to any |
| 48 |
particular database), and creating the <literal>postgres</literal>, |
| 49 |
<literal>template1</literal>, and <literal>template0</literal> databases. |
| 50 |
The <literal>postgres</literal> database is a default database meant |
| 51 |
for use by users, utilities and third party applications. |
| 52 |
<literal>template1</literal> and <literal>template0</literal> are |
| 53 |
meant as source databases to be copied by later <command>CREATE |
| 54 |
DATABASE</command> commands. <literal>template0</literal> should never |
| 55 |
be modified, but you can add objects to <literal>template1</literal>, |
| 56 |
which by default will be copied into databases created later. See |
| 57 |
<xref linkend="manage-ag-templatedbs"/> for more details. |
| 58 |
</para> |
| 59 |
|
| 60 |
<para> |
| 61 |
Although <command>initdb</command> will attempt to create the |
| 62 |
specified data directory, it might not have permission if the parent |
| 63 |
directory of the desired data directory is root-owned. To initialize |
| 64 |
in such a setup, create an empty data directory as root, then use |
| 65 |
<command>chown</command> to assign ownership of that directory to the |
| 66 |
database user account, then <command>su</command> to become the |
| 67 |
database user to run <command>initdb</command>. |
| 68 |
</para> |
| 69 |
|
| 70 |
<para> |
| 71 |
<command>initdb</command> must be run as the user that will own the |
| 72 |
server process, because the server needs to have access to the |
| 73 |
files and directories that <command>initdb</command> creates. |
| 74 |
Since the server cannot be run as root, you must not run |
| 75 |
<command>initdb</command> as root either. (It will in fact refuse |
| 76 |
to do so.) |
| 77 |
</para> |
| 78 |
|
| 79 |
<para> |
| 80 |
For security reasons the new cluster created by <command>initdb</command> |
| 81 |
will only be accessible by the cluster owner by default. The |
| 82 |
<option>--allow-group-access</option> option allows any user in the same |
| 83 |
group as the cluster owner to read files in the cluster. This is useful |
| 84 |
for performing backups as a non-privileged user. |
| 85 |
</para> |
| 86 |
|
| 87 |
<para> |
| 88 |
<command>initdb</command> initializes the database cluster's default locale |
| 89 |
and character set encoding. These can also be set separately for each |
| 90 |
database when it is created. <command>initdb</command> determines those |
| 91 |
settings for the template databases, which will serve as the default for |
| 92 |
all other databases. |
| 93 |
</para> |
| 94 |
|
| 95 |
<para> |
| 96 |
By default, <command>initdb</command> uses the locale provider |
| 97 |
<literal>libc</literal> (see <xref linkend="locale-providers"/>). The |
| 98 |
<literal>libc</literal> locale provider takes the locale settings from the |
| 99 |
environment, and determines the encoding from the locale settings. |
| 100 |
</para> |
| 101 |
|
| 102 |
<para> |
| 103 |
To choose a different locale for the cluster, use the option |
| 104 |
<option>--locale</option>. There are also individual options |
| 105 |
<option>--lc-*</option> and <option>--icu-locale</option> (see below) to |
| 106 |
set values for the individual locale categories. Note that inconsistent |
| 107 |
settings for different locale categories can give nonsensical results, so |
| 108 |
this should be used with care. |
| 109 |
</para> |
| 110 |
|
| 111 |
<para> |
| 112 |
Alternatively, <command>initdb</command> can use the ICU library to provide |
| 113 |
locale services by specifying <literal>--locale-provider=icu</literal>. The |
| 114 |
server must be built with ICU support. To choose the specific ICU locale ID |
| 115 |
to apply, use the option <option>--icu-locale</option>. Note that for |
| 116 |
implementation reasons and to support legacy code, |
| 117 |
<command>initdb</command> will still select and initialize libc locale |
| 118 |
settings when the ICU locale provider is used. |
| 119 |
</para> |
| 120 |
|
| 121 |
<para> |
| 122 |
When <command>initdb</command> runs, it will print out the locale settings |
| 123 |
it has chosen. If you have complex requirements or specified multiple |
| 124 |
options, it is advisable to check that the result matches what was |
| 125 |
intended. |
| 126 |
</para> |
| 127 |
|
| 128 |
<para> |
| 129 |
More details about locale settings can be found in <xref |
| 130 |
linkend="locale"/>. |
| 131 |
</para> |
| 132 |
|
| 133 |
<para> |
| 134 |
To alter the default encoding, use the <option>--encoding</option>. |
| 135 |
More details can be found in <xref linkend="multibyte"/>. |
| 136 |
</para> |
| 137 |
|
| 138 |
</refsect1> |
| 139 |
|
| 140 |
<refsect1> |
| 141 |
<title>Options</title> |
| 142 |
|
| 143 |
<para> |
| 144 |
<variablelist> |
| 145 |
<varlistentry id="app-initdb-option-auth"> |
| 146 |
<term><option>-A <replaceable class="parameter">authmethod</replaceable></option></term> |
| 147 |
<term><option>--auth=<replaceable class="parameter">authmethod</replaceable></option></term> |
| 148 |
<listitem> |
| 149 |
<para> |
| 150 |
This option specifies the default authentication method for local |
| 151 |
users used in <filename>pg_hba.conf</filename> (<literal>host</literal> |
| 152 |
and <literal>local</literal> lines). See <xref linkend="auth-pg-hba-conf"/> |
| 153 |
for an overview of valid values. |
| 154 |
</para> |
| 155 |
|
| 156 |
<para> |
| 157 |
<command>initdb</command> will |
| 158 |
prepopulate <filename>pg_hba.conf</filename> entries using the |
| 159 |
specified authentication method for non-replication as well as |
| 160 |
replication connections. |
| 161 |
</para> |
| 162 |
|
| 163 |
<para> |
| 164 |
Do not use <literal>trust</literal> unless you trust all local users on your |
| 165 |
system. <literal>trust</literal> is the default for ease of installation. |
| 166 |
</para> |
| 167 |
</listitem> |
| 168 |
</varlistentry> |
| 169 |
|
| 170 |
<varlistentry id="app-initdb-option-auth-host"> |
| 171 |
<term><option>--auth-host=<replaceable class="parameter">authmethod</replaceable></option></term> |
| 172 |
<listitem> |
| 173 |
<para> |
| 174 |
This option specifies the authentication method for local users via |
| 175 |
TCP/IP connections used in <filename>pg_hba.conf</filename> |
| 176 |
(<literal>host</literal> lines). |
| 177 |
</para> |
| 178 |
</listitem> |
| 179 |
</varlistentry> |
| 180 |
|
| 181 |
<varlistentry id="app-initdb-option-auth-local"> |
| 182 |
<term><option>--auth-local=<replaceable class="parameter">authmethod</replaceable></option></term> |
| 183 |
<listitem> |
| 184 |
<para> |
| 185 |
This option specifies the authentication method for local users via |
| 186 |
Unix-domain socket connections used in <filename>pg_hba.conf</filename> |
| 187 |
(<literal>local</literal> lines). |
| 188 |
</para> |
| 189 |
</listitem> |
| 190 |
</varlistentry> |
| 191 |
|
| 192 |
<varlistentry id="app-initdb-option-pgdata"> |
| 193 |
<term><option>-D <replaceable class="parameter">directory</replaceable></option></term> |
| 194 |
<term><option>--pgdata=<replaceable class="parameter">directory</replaceable></option></term> |
| 195 |
<listitem> |
| 196 |
<para> |
| 197 |
This option specifies the directory where the database cluster |
| 198 |
should be stored. This is the only information required by |
| 199 |
<command>initdb</command>, but you can avoid writing it by |
| 200 |
setting the <envar>PGDATA</envar> environment variable, which |
| 201 |
can be convenient since the database server |
| 202 |
(<command>postgres</command>) can find the data |
| 203 |
directory later by the same variable. |
| 204 |
</para> |
| 205 |
</listitem> |
| 206 |
</varlistentry> |
| 207 |
|
| 208 |
<varlistentry id="app-initdb-option-encoding"> |
| 209 |
<term><option>-E <replaceable class="parameter">encoding</replaceable></option></term> |
| 210 |
<term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term> |
| 211 |
<listitem> |
| 212 |
<para> |
| 213 |
Selects the encoding of the template databases. This will also be the |
| 214 |
default encoding of any database you create later, unless you override |
| 215 |
it then. The character sets supported by the |
| 216 |
<productname>PostgreSQL</productname> server are described in <xref |
| 217 |
linkend="multibyte-charset-supported"/>. |
| 218 |
</para> |
| 219 |
<para> |
| 220 |
By default, the template database encoding is derived from the |
| 221 |
locale. If <xref linkend="app-initdb-option-no-locale"/> is specified |
| 222 |
(or equivalently, if the locale is <literal>C</literal> or |
| 223 |
<literal>POSIX</literal>), then the default is <literal>UTF8</literal> |
| 224 |
for the ICU provider and <literal>SQL_ASCII</literal> for the |
| 225 |
<literal>libc</literal> provider. |
| 226 |
</para> |
| 227 |
</listitem> |
| 228 |
</varlistentry> |
| 229 |
|
| 230 |
<varlistentry id="app-initdb-allow-group-access"> |
| 231 |
<term><option>-g</option></term> |
| 232 |
<term><option>--allow-group-access</option></term> |
| 233 |
<listitem> |
| 234 |
<para> |
| 235 |
Allows users in the same group as the cluster owner to read all cluster |
| 236 |
files created by <command>initdb</command>. This option is ignored |
| 237 |
on <productname>Windows</productname> as it does not support |
| 238 |
<acronym>POSIX</acronym>-style group permissions. |
| 239 |
</para> |
| 240 |
</listitem> |
| 241 |
</varlistentry> |
| 242 |
|
| 243 |
<varlistentry id="app-initdb-icu-locale"> |
| 244 |
<term><option>--icu-locale=<replaceable>locale</replaceable></option></term> |
| 245 |
<listitem> |
| 246 |
<para> |
| 247 |
Specifies the ICU locale when the ICU provider is used. Locale support |
| 248 |
is described in <xref linkend="locale"/>. |
| 249 |
</para> |
| 250 |
</listitem> |
| 251 |
</varlistentry> |
| 252 |
|
| 253 |
<varlistentry id="app-initdb-icu-rules"> |
| 254 |
<term><option>--icu-rules=<replaceable>rules</replaceable></option></term> |
| 255 |
<listitem> |
| 256 |
<para> |
| 257 |
Specifies additional collation rules to customize the behavior of the |
| 258 |
default collation. This is supported for ICU only. |
| 259 |
</para> |
| 260 |
</listitem> |
| 261 |
</varlistentry> |
| 262 |
|
| 263 |
<varlistentry id="app-initdb-data-checksums"> |
| 264 |
<term><option>-k</option></term> |
| 265 |
<term><option>--data-checksums</option></term> |
| 266 |
<listitem> |
| 267 |
<para> |
| 268 |
Use checksums on data pages to help detect corruption by the I/O |
| 269 |
system that would otherwise be silent. This is enabled by default; |
| 270 |
use <xref linkend="app-initdb-no-data-checksums"/> to disable |
| 271 |
checksums. |
| 272 |
</para> |
| 273 |
|
| 274 |
<para> |
| 275 |
Enabling checksums |
| 276 |
might incur a small performance penalty. If set, checksums |
| 277 |
are calculated for all objects, in all databases. All checksum |
| 278 |
failures will be reported in the |
| 279 |
<link linkend="monitoring-pg-stat-database-view"> |
| 280 |
<structname>pg_stat_database</structname></link> view. |
| 281 |
See <xref linkend="checksums" /> for details. |
| 282 |
</para> |
| 283 |
</listitem> |
| 284 |
</varlistentry> |
| 285 |
|
| 286 |
<varlistentry id="app-initdb-option-locale"> |
| 287 |
<term><option>--locale=<replaceable>locale</replaceable></option></term> |
| 288 |
<listitem> |
| 289 |
<para> |
| 290 |
Sets the default locale for the database cluster. If this |
| 291 |
option is not specified, the locale is inherited from the |
| 292 |
environment that <command>initdb</command> runs in. Locale |
| 293 |
support is described in <xref linkend="locale"/>. |
| 294 |
</para> |
| 295 |
<para> |
| 296 |
If <option>--locale-provider</option> is <literal>builtin</literal>, |
| 297 |
<option>--locale</option> or <option>--builtin-locale</option> must be |
| 298 |
specified and set to <literal>C</literal>, <literal>C.UTF-8</literal> |
| 299 |
or <literal>PG_UNICODE_FAST</literal>. |
| 300 |
</para> |
| 301 |
</listitem> |
| 302 |
</varlistentry> |
| 303 |
|
| 304 |
<varlistentry id="app-initdb-option-lc-collate"> |
| 305 |
<term><option>--lc-collate=<replaceable>locale</replaceable></option></term> |
| 306 |
<term><option>--lc-ctype=<replaceable>locale</replaceable></option></term> |
| 307 |
<term><option>--lc-messages=<replaceable>locale</replaceable></option></term> |
| 308 |
<term><option>--lc-monetary=<replaceable>locale</replaceable></option></term> |
| 309 |
<term><option>--lc-numeric=<replaceable>locale</replaceable></option></term> |
| 310 |
<term><option>--lc-time=<replaceable>locale</replaceable></option></term> |
| 311 |
|
| 312 |
<listitem> |
| 313 |
<para> |
| 314 |
Like <option>--locale</option>, but only sets the locale in |
| 315 |
the specified category. |
| 316 |
</para> |
| 317 |
</listitem> |
| 318 |
</varlistentry> |
| 319 |
|
| 320 |
<varlistentry id="app-initdb-option-no-locale"> |
| 321 |
<term><option>--no-locale</option></term> |
| 322 |
<listitem> |
| 323 |
<para> |
| 324 |
Equivalent to <option>--locale=C</option>. |
| 325 |
</para> |
| 326 |
</listitem> |
| 327 |
</varlistentry> |
| 328 |
|
| 329 |
<varlistentry id="app-initdb-builtin-locale"> |
| 330 |
<term><option>--builtin-locale=<replaceable>locale</replaceable></option></term> |
| 331 |
<listitem> |
| 332 |
<para> |
| 333 |
Specifies the locale name when the builtin provider is used. Locale support |
| 334 |
is described in <xref linkend="locale"/>. |
| 335 |
</para> |
| 336 |
</listitem> |
| 337 |
</varlistentry> |
| 338 |
|
| 339 |
<varlistentry id="app-initdb-option-locale-provider"> |
| 340 |
<term><option>--locale-provider={<literal>builtin</literal>|<literal>libc</literal>|<literal>icu</literal>}</option></term> |
| 341 |
<listitem> |
| 342 |
<para> |
| 343 |
This option sets the locale provider for databases created in the new |
| 344 |
cluster. It can be overridden in the <command>CREATE |
| 345 |
DATABASE</command> command when new databases are subsequently |
| 346 |
created. The default is <literal>libc</literal> (see <xref |
| 347 |
linkend="locale-providers"/>). |
| 348 |
</para> |
| 349 |
</listitem> |
| 350 |
</varlistentry> |
| 351 |
|
| 352 |
<varlistentry id="app-initdb-no-data-checksums"> |
| 353 |
<term><option>--no-data-checksums</option></term> |
| 354 |
<listitem> |
| 355 |
<para> |
| 356 |
Do not enable data checksums. |
| 357 |
</para> |
| 358 |
</listitem> |
| 359 |
</varlistentry> |
| 360 |
|
| 361 |
<varlistentry id="app-initdb-option-pwfile"> |
| 362 |
<term><option>--pwfile=<replaceable>filename</replaceable></option></term> |
| 363 |
<listitem> |
| 364 |
<para> |
| 365 |
Makes <command>initdb</command> read the bootstrap superuser's password |
| 366 |
from a file. The first line of the file is taken as the password. |
| 367 |
</para> |
| 368 |
</listitem> |
| 369 |
</varlistentry> |
| 370 |
|
| 371 |
<varlistentry id="app-initdb-option-text-search-config"> |
| 372 |
<term><option>-T <replaceable>config</replaceable></option></term> |
| 373 |
<term><option>--text-search-config=<replaceable>config</replaceable></option></term> |
| 374 |
<listitem> |
| 375 |
<para> |
| 376 |
Sets the default text search configuration. |
| 377 |
See <xref linkend="guc-default-text-search-config"/> for further information. |
| 378 |
</para> |
| 379 |
</listitem> |
| 380 |
</varlistentry> |
| 381 |
|
| 382 |
<varlistentry id="app-initdb-option-username"> |
| 383 |
<term><option>-U <replaceable class="parameter">username</replaceable></option></term> |
| 384 |
<term><option>--username=<replaceable class="parameter">username</replaceable></option></term> |
| 385 |
<listitem> |
| 386 |
<para> |
| 387 |
Sets the user name of the |
| 388 |
<glossterm linkend="glossary-bootstrap-superuser">bootstrap superuser</glossterm>. |
| 389 |
This defaults to the name of the operating-system user running |
| 390 |
<command>initdb</command>. |
| 391 |
</para> |
| 392 |
</listitem> |
| 393 |
</varlistentry> |
| 394 |
|
| 395 |
<varlistentry id="app-initdb-option-pwprompt"> |
| 396 |
<term><option>-W</option></term> |
| 397 |
<term><option>--pwprompt</option></term> |
| 398 |
<listitem> |
| 399 |
<para> |
| 400 |
Makes <command>initdb</command> prompt for a password |
| 401 |
to give the bootstrap superuser. If you don't plan on using password |
| 402 |
authentication, this is not important. Otherwise you won't be |
| 403 |
able to use password authentication until you have a password |
| 404 |
set up. |
| 405 |
</para> |
| 406 |
</listitem> |
| 407 |
</varlistentry> |
| 408 |
|
| 409 |
<varlistentry id="app-initdb-option-waldir"> |
| 410 |
<term><option>-X <replaceable class="parameter">directory</replaceable></option></term> |
| 411 |
<term><option>--waldir=<replaceable class="parameter">directory</replaceable></option></term> |
| 412 |
<listitem> |
| 413 |
<para> |
| 414 |
This option specifies the directory where the write-ahead log |
| 415 |
should be stored. |
| 416 |
</para> |
| 417 |
</listitem> |
| 418 |
</varlistentry> |
| 419 |
|
| 420 |
<varlistentry id="app-initdb-option-wal-segsize"> |
| 421 |
<term><option>--wal-segsize=<replaceable>size</replaceable></option></term> |
| 422 |
<listitem> |
| 423 |
<para> |
| 424 |
Set the <firstterm>WAL segment size</firstterm>, in megabytes. This |
| 425 |
is the size of each individual file in the WAL log. The default size |
| 426 |
is 16 megabytes. The value must be a power of 2 between 1 and 1024 |
| 427 |
(megabytes). This option can only be set during initialization, and |
| 428 |
cannot be changed later. |
| 429 |
</para> |
| 430 |
|
| 431 |
<para> |
| 432 |
It may be useful to adjust this size to control the granularity of |
| 433 |
WAL log shipping or archiving. Also, in databases with a high volume |
| 434 |
of WAL, the sheer number of WAL files per directory can become a |
| 435 |
performance and management problem. Increasing the WAL file size |
| 436 |
will reduce the number of WAL files. |
| 437 |
</para> |
| 438 |
</listitem> |
| 439 |
</varlistentry> |
| 440 |
</variablelist> |
| 441 |
</para> |
| 442 |
|
| 443 |
<para> |
| 444 |
Other, less commonly used, options are also available: |
| 445 |
|
| 446 |
<variablelist> |
| 447 |
<varlistentry id="app-initdb-option-set"> |
| 448 |
<term><option>-c <replaceable>name</replaceable>=<replaceable>value</replaceable></option></term> |
| 449 |
<term><option>--set <replaceable>name</replaceable>=<replaceable>value</replaceable></option></term> |
| 450 |
<listitem> |
| 451 |
<para> |
| 452 |
Forcibly set the server parameter <replaceable>name</replaceable> |
| 453 |
to <replaceable>value</replaceable> during <command>initdb</command>, |
| 454 |
and also install that setting in the |
| 455 |
generated <filename>postgresql.conf</filename> file, |
| 456 |
so that it will apply during future server runs. |
| 457 |
This option can be given more than once to set several parameters. |
| 458 |
It is primarily useful when the environment is such that the server |
| 459 |
will not start at all using the default parameters. |
| 460 |
</para> |
| 461 |
</listitem> |
| 462 |
</varlistentry> |
| 463 |
|
| 464 |
<varlistentry id="app-initdb-option-debug"> |
| 465 |
<term><option>-d</option></term> |
| 466 |
<term><option>--debug</option></term> |
| 467 |
<listitem> |
| 468 |
<para> |
| 469 |
Print debugging output from the bootstrap backend and a few other |
| 470 |
messages of lesser interest for the general public. |
| 471 |
The bootstrap backend is the program <command>initdb</command> |
| 472 |
uses to create the catalog tables. This option generates a tremendous |
| 473 |
amount of extremely boring output. |
| 474 |
</para> |
| 475 |
</listitem> |
| 476 |
</varlistentry> |
| 477 |
|
| 478 |
<varlistentry id="app-initdb-option-discard-caches"> |
| 479 |
<term><option>--discard-caches</option></term> |
| 480 |
<listitem> |
| 481 |
<para> |
| 482 |
Run the bootstrap backend with the |
| 483 |
<literal>debug_discard_caches=1</literal> option. |
| 484 |
This takes a very long time and is only of use for deep debugging. |
| 485 |
</para> |
| 486 |
</listitem> |
| 487 |
</varlistentry> |
| 488 |
|
| 489 |
<varlistentry id="app-initdb-option-l"> |
| 490 |
<term><option>-L <replaceable class="parameter">directory</replaceable></option></term> |
| 491 |
<listitem> |
| 492 |
<para> |
| 493 |
Specifies where <command>initdb</command> should find |
| 494 |
its input files to initialize the database cluster. This is |
| 495 |
normally not necessary. You will be told if you need to |
| 496 |
specify their location explicitly. |
| 497 |
</para> |
| 498 |
</listitem> |
| 499 |
</varlistentry> |
| 500 |
|
| 501 |
<varlistentry id="app-initdb-option-no-clean"> |
| 502 |
<term><option>-n</option></term> |
| 503 |
<term><option>--no-clean</option></term> |
| 504 |
<listitem> |
| 505 |
<para> |
| 506 |
By default, when <command>initdb</command> |
| 507 |
determines that an error prevented it from completely creating the database |
| 508 |
cluster, it removes any files it might have created before discovering |
| 509 |
that it cannot finish the job. This option inhibits tidying-up and is |
| 510 |
thus useful for debugging. |
| 511 |
</para> |
| 512 |
</listitem> |
| 513 |
</varlistentry> |
| 514 |
|
| 515 |
<varlistentry id="app-initdb-option-no-sync"> |
| 516 |
<term><option>-N</option></term> |
| 517 |
<term><option>--no-sync</option></term> |
| 518 |
<listitem> |
| 519 |
<para> |
| 520 |
By default, <command>initdb</command> will wait for all files to be |
| 521 |
written safely to disk. This option causes <command>initdb</command> |
| 522 |
to return without waiting, which is faster, but means that a |
| 523 |
subsequent operating system crash can leave the data directory |
| 524 |
corrupt. Generally, this option is useful for testing, but should not |
| 525 |
be used when creating a production installation. |
| 526 |
</para> |
| 527 |
</listitem> |
| 528 |
</varlistentry> |
| 529 |
|
| 530 |
<varlistentry id="app-initdb-option-no-sync-data-files"> |
| 531 |
<term><option>--no-sync-data-files</option></term> |
| 532 |
<listitem> |
| 533 |
<para> |
| 534 |
By default, <command>initdb</command> safely writes all database files |
| 535 |
to disk. This option instructs <command>initdb</command> to skip |
| 536 |
synchronizing all files in the individual database directories, the |
| 537 |
database directories themselves, and the tablespace directories, i.e., |
| 538 |
everything in the <filename>base</filename> subdirectory and any other |
| 539 |
tablespace directories. Other files, such as those in |
| 540 |
<literal>pg_wal</literal> and <literal>pg_xact</literal>, will still be |
| 541 |
synchronized unless the <option>--no-sync</option> option is also |
| 542 |
specified. |
| 543 |
</para> |
| 544 |
<para> |
| 545 |
Note that if <option>--no-sync-data-files</option> is used in |
| 546 |
conjunction with <option>--sync-method=syncfs</option>, some or all of |
| 547 |
the aforementioned files and directories will be synchronized because |
| 548 |
<literal>syncfs</literal> processes entire file systems. |
| 549 |
</para> |
| 550 |
<para> |
| 551 |
This option is primarily intended for internal use by tools that |
| 552 |
separately ensure the skipped files are synchronized to disk. |
| 553 |
</para> |
| 554 |
</listitem> |
| 555 |
</varlistentry> |
| 556 |
|
| 557 |
<varlistentry id="app-initdb-option-no-instructions"> |
| 558 |
<term><option>--no-instructions</option></term> |
| 559 |
<listitem> |
| 560 |
<para> |
| 561 |
By default, <command>initdb</command> will write instructions for how |
| 562 |
to start the cluster at the end of its output. This option causes |
| 563 |
those instructions to be left out. This is primarily intended for use |
| 564 |
by tools that wrap <command>initdb</command> in platform-specific |
| 565 |
behavior, where those instructions are likely to be incorrect. |
| 566 |
</para> |
| 567 |
</listitem> |
| 568 |
</varlistentry> |
| 569 |
|
| 570 |
<varlistentry id="app-initdb-option-show"> |
| 571 |
<term><option>-s</option></term> |
| 572 |
<term><option>--show</option></term> |
| 573 |
<listitem> |
| 574 |
<para> |
| 575 |
Show internal settings and exit, without doing anything else. This |
| 576 |
can be used to debug the <application>initdb</application> |
| 577 |
installation. |
| 578 |
</para> |
| 579 |
</listitem> |
| 580 |
</varlistentry> |
| 581 |
|
| 582 |
<varlistentry id="app-initdb-option-sync-method"> |
| 583 |
<term><option>--sync-method=<replaceable>method</replaceable></option></term> |
| 584 |
<listitem> |
| 585 |
<para> |
| 586 |
When set to <literal>fsync</literal>, which is the default, |
| 587 |
<command>initdb</command> will recursively open and synchronize all |
| 588 |
files in the data directory. The search for files will follow symbolic |
| 589 |
links for the WAL directory and each configured tablespace. |
| 590 |
</para> |
| 591 |
<para> |
| 592 |
On Linux, <literal>syncfs</literal> may be used instead to ask the |
| 593 |
operating system to synchronize the whole file systems that contain the |
| 594 |
data directory, the WAL files, and each tablespace. See |
| 595 |
<xref linkend="guc-recovery-init-sync-method"/> for information about |
| 596 |
the caveats to be aware of when using <literal>syncfs</literal>. |
| 597 |
</para> |
| 598 |
<para> |
| 599 |
This option has no effect when <option>--no-sync</option> is used. |
| 600 |
</para> |
| 601 |
</listitem> |
| 602 |
</varlistentry> |
| 603 |
|
| 604 |
<varlistentry id="app-initdb-option-sync-only"> |
| 605 |
<term><option>-S</option></term> |
| 606 |
<term><option>--sync-only</option></term> |
| 607 |
<listitem> |
| 608 |
<para> |
| 609 |
Safely write all database files to disk and exit. This does not |
| 610 |
perform any of the normal <application>initdb</application> operations. |
| 611 |
Generally, this option is useful for ensuring reliable recovery after |
| 612 |
changing <xref linkend="guc-fsync"/> from <literal>off</literal> to |
| 613 |
<literal>on</literal>. |
| 614 |
</para> |
| 615 |
</listitem> |
| 616 |
</varlistentry> |
| 617 |
</variablelist> |
| 618 |
</para> |
| 619 |
|
| 620 |
<para> |
| 621 |
Other options: |
| 622 |
|
| 623 |
<variablelist> |
| 624 |
<varlistentry id="app-initdb-option-version"> |
| 625 |
<term><option>-V</option></term> |
| 626 |
<term><option>--version</option></term> |
| 627 |
<listitem> |
| 628 |
<para> |
| 629 |
Print the <application>initdb</application> version and exit. |
| 630 |
</para> |
| 631 |
</listitem> |
| 632 |
</varlistentry> |
| 633 |
|
| 634 |
<varlistentry id="app-initdb-option-help"> |
| 635 |
<term><option>-?</option></term> |
| 636 |
<term><option>--help</option></term> |
| 637 |
<listitem> |
| 638 |
<para> |
| 639 |
Show help about <application>initdb</application> command line |
| 640 |
arguments, and exit. |
| 641 |
</para> |
| 642 |
</listitem> |
| 643 |
</varlistentry> |
| 644 |
|
| 645 |
</variablelist> |
| 646 |
</para> |
| 647 |
|
| 648 |
</refsect1> |
| 649 |
|
| 650 |
<refsect1> |
| 651 |
<title>Environment</title> |
| 652 |
|
| 653 |
<variablelist> |
| 654 |
<varlistentry id="app-initdb-environment-pgdata"> |
| 655 |
<term><envar>PGDATA</envar></term> |
| 656 |
|
| 657 |
<listitem> |
| 658 |
<para> |
| 659 |
Specifies the directory where the database cluster is to be |
| 660 |
stored; can be overridden using the <option>-D</option> option. |
| 661 |
</para> |
| 662 |
</listitem> |
| 663 |
</varlistentry> |
| 664 |
|
| 665 |
<varlistentry id="app-initdb-environment-pg-color"> |
| 666 |
<term><envar>PG_COLOR</envar></term> |
| 667 |
<listitem> |
| 668 |
<para> |
| 669 |
Specifies whether to use color in diagnostic messages. Possible values |
| 670 |
are <literal>always</literal>, <literal>auto</literal> and |
| 671 |
<literal>never</literal>. |
| 672 |
</para> |
| 673 |
</listitem> |
| 674 |
</varlistentry> |
| 675 |
|
| 676 |
<varlistentry id="app-initdb-environment-tz"> |
| 677 |
<term><envar>TZ</envar></term> |
| 678 |
|
| 679 |
<listitem> |
| 680 |
<para> |
| 681 |
Specifies the default time zone of the created database cluster. The |
| 682 |
value should be a full time zone name |
| 683 |
(see <xref linkend="datatype-timezones"/>). |
| 684 |
</para> |
| 685 |
</listitem> |
| 686 |
</varlistentry> |
| 687 |
</variablelist> |
| 688 |
|
| 689 |
</refsect1> |
| 690 |
|
| 691 |
<refsect1> |
| 692 |
<title>Notes</title> |
| 693 |
|
| 694 |
<para> |
| 695 |
<command>initdb</command> can also be invoked via |
| 696 |
<command>pg_ctl initdb</command>. |
| 697 |
</para> |
| 698 |
</refsect1> |
| 699 |
|
| 700 |
<refsect1> |
| 701 |
<title>See Also</title> |
| 702 |
|
| 703 |
<simplelist type="inline"> |
| 704 |
<member><xref linkend="app-pg-ctl"/></member> |
| 705 |
<member><xref linkend="app-postgres"/></member> |
| 706 |
<member><xref linkend="auth-pg-hba-conf"/></member> |
| 707 |
</simplelist> |
| 708 |
</refsect1> |
| 709 |
|
| 710 |
</refentry> |