3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "INITDB" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 initdb \- create a new PostgreSQL database cluster
33 .HP \w'\fBinitdb\fR\ 'u
34 \fBinitdb\fR [\fIoption\fR...] [\fB\-\-pgdata\fR | \fB\-D\fR]\fI directory\fR
42 Creating a database cluster consists of creating the
44 in which the cluster data will live, generating the shared catalog tables (tables that belong to the whole cluster rather than to any particular database), and creating the
50 database is a default database meant for use by users, utilities and third party applications\&.
54 are meant as source databases to be copied by later
58 should never be modified, but you can add objects to
59 template1, which by default will be copied into databases created later\&. See
65 will attempt to create the specified data directory, it might not have permission if the parent directory of the desired data directory is root\-owned\&. To initialize in such a setup, create an empty data directory as root, then use
67 to assign ownership of that directory to the database user account, then
69 to become the database user to run
73 must be run as the user that will own the server process, because the server needs to have access to the files and directories that
75 creates\&. Since the server cannot be run as root, you must not run
77 as root either\&. (It will in fact refuse to do so\&.)
79 For security reasons the new cluster created by
81 will only be accessible by the cluster owner by default\&. The
82 \fB\-\-allow\-group\-access\fR
83 option allows any user in the same group as the cluster owner to read files in the cluster\&. This is useful for performing backups as a non\-privileged user\&.
86 initializes the database cluster\*(Aqs default locale and character set encoding\&. These can also be set separately for each database when it is created\&.
88 determines those settings for the template databases, which will serve as the default for all other databases\&.
92 uses the locale provider
95 Section\ \&23.1.4)\&. The
97 locale provider takes the locale settings from the environment, and determines the encoding from the locale settings\&.
99 To choose a different locale for the cluster, use the option
100 \fB\-\-locale\fR\&. There are also individual options
103 \fB\-\-icu\-locale\fR
104 (see below) to set values for the individual locale categories\&. Note that inconsistent settings for different locale categories can give nonsensical results, so this should be used with care\&.
108 can use the ICU library to provide locale services by specifying
109 \-\-locale\-provider=icu\&. The server must be built with ICU support\&. To choose the specific ICU locale ID to apply, use the option
110 \fB\-\-icu\-locale\fR\&. Note that for implementation reasons and to support legacy code,
112 will still select and initialize libc locale settings when the ICU locale provider is used\&.
116 runs, it will print out the locale settings it has chosen\&. If you have complex requirements or specified multiple options, it is advisable to check that the result matches what was intended\&.
118 More details about locale settings can be found in
121 To alter the default encoding, use the
122 \fB\-\-encoding\fR\&. More details can be found in
127 \fB\-A \fR\fB\fIauthmethod\fR\fR
129 \fB\-\-auth=\fR\fB\fIauthmethod\fR\fR
131 This option specifies the default authentication method for local users used in
138 for an overview of valid values\&.
143 entries using the specified authentication method for non\-replication as well as replication connections\&.
147 unless you trust all local users on your system\&.
149 is the default for ease of installation\&.
152 \fB\-\-auth\-host=\fR\fB\fIauthmethod\fR\fR
154 This option specifies the authentication method for local users via TCP/IP connections used in
160 \fB\-\-auth\-local=\fR\fB\fIauthmethod\fR\fR
162 This option specifies the authentication method for local users via Unix\-domain socket connections used in
168 \fB\-D \fR\fB\fIdirectory\fR\fR
170 \fB\-\-pgdata=\fR\fB\fIdirectory\fR\fR
172 This option specifies the directory where the database cluster should be stored\&. This is the only information required by
173 \fBinitdb\fR, but you can avoid writing it by setting the
175 environment variable, which can be convenient since the database server (\fBpostgres\fR) can find the data directory later by the same variable\&.
178 \fB\-E \fR\fB\fIencoding\fR\fR
180 \fB\-\-encoding=\fR\fB\fIencoding\fR\fR
182 Selects the encoding of the template databases\&. This will also be the default encoding of any database you create later, unless you override it then\&. The character sets supported by the
184 server are described in
187 By default, the template database encoding is derived from the locale\&. If
189 is specified (or equivalently, if the locale is
192 POSIX), then the default is
194 for the ICU provider and
203 \fB\-\-allow\-group\-access\fR
205 Allows users in the same group as the cluster owner to read all cluster files created by
206 \fBinitdb\fR\&. This option is ignored on
208 as it does not support
209 POSIX\-style group permissions\&.
212 \fB\-\-icu\-locale=\fR\fB\fIlocale\fR\fR
214 Specifies the ICU locale when the ICU provider is used\&. Locale support is described in
218 \fB\-\-icu\-rules=\fR\fB\fIrules\fR\fR
220 Specifies additional collation rules to customize the behavior of the default collation\&. This is supported for ICU only\&.
225 \fB\-\-data\-checksums\fR
227 Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent\&. This is enabled by default; use
228 \fB\-\-no\-data\-checksums\fR
229 to disable checksums\&.
231 Enabling checksums might incur a small performance penalty\&. If set, checksums are calculated for all objects, in all databases\&. All checksum failures will be reported in the
238 \fB\-\-locale=\fR\fB\fIlocale\fR\fR
240 Sets the default locale for the database cluster\&. If this option is not specified, the locale is inherited from the environment that
242 runs in\&. Locale support is described in
246 \fB\-\-locale\-provider\fR
251 \fB\-\-builtin\-locale\fR
252 must be specified and set to
259 \fB\-\-lc\-collate=\fR\fB\fIlocale\fR\fR
261 \fB\-\-lc\-ctype=\fR\fB\fIlocale\fR\fR
263 \fB\-\-lc\-messages=\fR\fB\fIlocale\fR\fR
265 \fB\-\-lc\-monetary=\fR\fB\fIlocale\fR\fR
267 \fB\-\-lc\-numeric=\fR\fB\fIlocale\fR\fR
269 \fB\-\-lc\-time=\fR\fB\fIlocale\fR\fR
272 \fB\-\-locale\fR, but only sets the locale in the specified category\&.
278 \fB\-\-locale=C\fR\&.
281 \fB\-\-builtin\-locale=\fR\fB\fIlocale\fR\fR
283 Specifies the locale name when the builtin provider is used\&. Locale support is described in
287 \fB\-\-locale\-provider={\fR\fBbuiltin\fR\fB|\fR\fBlibc\fR\fB|\fR\fBicu\fR\fB}\fR
289 This option sets the locale provider for databases created in the new cluster\&. It can be overridden in the
290 \fBCREATE DATABASE\fR
291 command when new databases are subsequently created\&. The default is
294 Section\ \&23.1.4)\&.
297 \fB\-\-no\-data\-checksums\fR
299 Do not enable data checksums\&.
302 \fB\-\-pwfile=\fR\fB\fIfilename\fR\fR
306 read the bootstrap superuser\*(Aqs password from a file\&. The first line of the file is taken as the password\&.
309 \fB\-T \fR\fB\fIconfig\fR\fR
311 \fB\-\-text\-search\-config=\fR\fB\fIconfig\fR\fR
313 Sets the default text search configuration\&. See
314 default_text_search_config
315 for further information\&.
318 \fB\-U \fR\fB\fIusername\fR\fR
320 \fB\-\-username=\fR\fB\fIusername\fR\fR
322 Sets the user name of the
323 bootstrap superuser\&. This defaults to the name of the operating\-system user running
333 prompt for a password to give the bootstrap superuser\&. If you don\*(Aqt plan on using password authentication, this is not important\&. Otherwise you won\*(Aqt be able to use password authentication until you have a password set up\&.
336 \fB\-X \fR\fB\fIdirectory\fR\fR
338 \fB\-\-waldir=\fR\fB\fIdirectory\fR\fR
340 This option specifies the directory where the write\-ahead log should be stored\&.
343 \fB\-\-wal\-segsize=\fR\fB\fIsize\fR\fR
346 WAL segment size, in megabytes\&. This is the size of each individual file in the WAL log\&. The default size is 16 megabytes\&. The value must be a power of 2 between 1 and 1024 (megabytes)\&. This option can only be set during initialization, and cannot be changed later\&.
348 It may be useful to adjust this size to control the granularity of WAL log shipping or archiving\&. Also, in databases with a high volume of WAL, the sheer number of WAL files per directory can become a performance and management problem\&. Increasing the WAL file size will reduce the number of WAL files\&.
351 Other, less commonly used, options are also available:
353 \fB\-c \fR\fB\fIname\fR\fR\fB=\fR\fB\fIvalue\fR\fR
355 \fB\-\-set \fR\fB\fIname\fR\fR\fB=\fR\fB\fIvalue\fR\fR
357 Forcibly set the server parameter
362 \fBinitdb\fR, and also install that setting in the generated
364 file, so that it will apply during future server runs\&. This option can be given more than once to set several parameters\&. It is primarily useful when the environment is such that the server will not start at all using the default parameters\&.
371 Print debugging output from the bootstrap backend and a few other messages of lesser interest for the general public\&. The bootstrap backend is the program
373 uses to create the catalog tables\&. This option generates a tremendous amount of extremely boring output\&.
376 \fB\-\-discard\-caches\fR
378 Run the bootstrap backend with the
379 debug_discard_caches=1
380 option\&. This takes a very long time and is only of use for deep debugging\&.
383 \fB\-L \fR\fB\fIdirectory\fR\fR
387 should find its input files to initialize the database cluster\&. This is normally not necessary\&. You will be told if you need to specify their location explicitly\&.
396 determines that an error prevented it from completely creating the database cluster, it removes any files it might have created before discovering that it cannot finish the job\&. This option inhibits tidying\-up and is thus useful for debugging\&.
405 will wait for all files to be written safely to disk\&. This option causes
407 to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt\&. Generally, this option is useful for testing, but should not be used when creating a production installation\&.
410 \fB\-\-no\-sync\-data\-files\fR
414 safely writes all database files to disk\&. This option instructs
416 to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i\&.e\&., everything in the
418 subdirectory and any other tablespace directories\&. Other files, such as those in
421 pg_xact, will still be synchronized unless the
423 option is also specified\&.
426 \fB\-\-no\-sync\-data\-files\fR
427 is used in conjunction with
428 \fB\-\-sync\-method=syncfs\fR, some or all of the aforementioned files and directories will be synchronized because
430 processes entire file systems\&.
432 This option is primarily intended for internal use by tools that separately ensure the skipped files are synchronized to disk\&.
435 \fB\-\-no\-instructions\fR
439 will write instructions for how to start the cluster at the end of its output\&. This option causes those instructions to be left out\&. This is primarily intended for use by tools that wrap
441 in platform\-specific behavior, where those instructions are likely to be incorrect\&.
448 Show internal settings and exit, without doing anything else\&. This can be used to debug the
453 \fB\-\-sync\-method=\fR\fB\fImethod\fR\fR
456 fsync, which is the default,
458 will recursively open and synchronize all files in the data directory\&. The search for files will follow symbolic links for the WAL directory and each configured tablespace\&.
462 may be used instead to ask the operating system to synchronize the whole file systems that contain the data directory, the WAL files, and each tablespace\&. See
463 recovery_init_sync_method
464 for information about the caveats to be aware of when using
467 This option has no effect when
476 Safely write all database files to disk and exit\&. This does not perform any of the normal
478 operations\&. Generally, this option is useful for ensuring reliable recovery after changing
503 command line arguments, and exit\&.
509 Specifies the directory where the database cluster is to be stored; can be overridden using the
516 Specifies whether to use color in diagnostic messages\&. Possible values are
525 Specifies the default time zone of the created database cluster\&. The value should be a full time zone name (see
531 can also be invoked via
532 \fBpg_ctl initdb\fR\&.
534 \fBpg_ctl\fR(1), \fBpostgres\fR(1), Section\ \&20.1