Linux "initdb" Command Line Options and Examples
create a new PostgreSQL database cluster

initdb creates a new PostgreSQL database cluster. A database cluster is a collection of databases that are managed by a single server instance.


Usage:

initdb [option...] [--pgdata | -D] directory






Command Line Options:

--auth
This option specifies the default authentication method for local users used in pg_hba.conf (host and local lines). initdb willprepopulate pg_hba.conf entries using the specified authentication method for non-replication as well as replication connections.Do not use trust unless you trust all local users on your system. trust is the default for ease of installation.
initdb --auth ...
--auth-host
This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf (host lines).
initdb --auth-host ...
--auth-local
This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf (locallines).
initdb --auth-local ...
--pgdata
This option specifies the directory where the database cluster should be stored. This is the only information required by initdb,but you can avoid writing it by setting the PGDATA environment variable, which can be convenient since the database server(postgres) can find the database directory later by the same variable.
initdb --pgdata ...
--encoding
Selects the encoding of the template database. This will also be the default encoding of any database you create later, unlessyou override it there. The default is derived from the locale, or SQL_ASCII if that does not work. The character sets supportedby the PostgreSQL server are described in Section 23.3.1.
initdb --encoding ...
--data-checksums
Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Enabling checksums mayincur a noticeable performance penalty. This option can only be set during initialization, and cannot be changed later. If set,checksums are calculated for all objects, in all databases.
initdb --data-checksums ...
--locale
Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environmentthat initdb runs in. Locale support is described in Section 23.1.
initdb --locale ...
--lc-time
Like --locale, but only sets the locale in the specified category.
initdb --lc-time ...
--no-locale
Equivalent to --locale=C.
initdb --no-locale ...
--no-sync
By default, initdb will wait for all files to be written safely to disk. This option causes initdb to return without waiting,which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this optionis useful for testing, but should not be used when creating a production installation.
initdb --no-sync ...
--pwfile
Makes initdb read the database superuser's password from a file. The first line of the file is taken as the password.
initdb --pwfile ...
--sync-only
Safely write all database files to disk and exit. This does not perform any of the normal initdb operations.
initdb --sync-only ...
--text-search-config
Sets the default text search configuration. See default_text_search_config for further information.
initdb --text-search-config ...
--username
Selects the user name of the database superuser. This defaults to the name of the effective user running initdb. It is really notimportant what the superuser's name is, but one might choose to keep the customary name postgres, even if the operating systemuser's name is different.
initdb --username ...
--pwprompt
Makes initdb prompt for a password to give the database superuser. If you don't plan on using password authentication, this isnot important. Otherwise you won't be able to use password authentication until you have a password set up.
initdb --pwprompt ...
--waldir
This option specifies the directory where the write-ahead log should be stored.Other, less commonly used, options are also available:
initdb --waldir ...
--debug
Print debugging output from the bootstrap backend and a few other messages of lesser interest for the general public. Thebootstrap backend is the program initdb uses to create the catalog tables. This option generates a tremendous amount of extremelyboring output.
initdb --debug ...
-L
Specifies where initdb should find its input files to initialize the database cluster. This is normally not necessary. You willbe told if you need to specify their location explicitly.
initdb -L ...
--no-clean
By default, when initdb determines that an error prevented it from completely creating the database cluster, it removes any filesit might have created before discovering that it cannot finish the job. This option inhibits tidying-up and is thus useful fordebugging.Other options:
initdb --no-clean ...
--version
Print the initdb version and exit.
initdb --version ...
--help
Show help about initdb command line arguments, and exit.ENVIRONMENTPGDATASpecifies the directory where the database cluster is to be stored; can be overridden using the -D option.TZSpecifies the default time zone of the created database cluster. The value should be a full time zone name (see Section 8.5.3).This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 33.14).NOTESinitdb can also be invoked via pg_ctl initdb.
initdb --help ...