{"Entry":{"collection":"tool","key":"initdb","name":"initdb","aliases":["initdb"],"metadata":{"aliases":["initdb"],"category":"Server applications","content_hash":"98b6ac7afe6324f4ff3d166e21ac8a6a02c2355ffffbc310333c7955642f8a84","derived_content_hash":"707af16b0627ba97f2f234016e3563d26c1f4976522552ec3c462c3f576845f4","imported_at":"2026-09-30T00:40:33.954987+08:00","name":"initdb","name_zh":"","slug":"initdb","summary":"initdb — create a new PostgreSQL database cluster"}},"Definition":{"Collection":"tool","Key":"initdb","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"initdb","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[{"description":"Specifies the directory where the database cluster is to be stored; can be overridden using the -D option.","name":"PGDATA"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Specifies the default time zone of the created database cluster. The value should be a full time zone name (see Section 8.5.3 ).","name":"TZ"}],"options":[{"description":"This option specifies the default authentication method for local users used in pg_hba.conf ( host and local lines). See Section 20.1 for an overview of valid values. initdb will prepopulate 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.","names":["-A authmethod","--auth= authmethod"],"signature":"-A authmethod --auth= authmethod"},{"description":"This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf ( host lines).","names":["--auth-host= authmethod"],"signature":"--auth-host= authmethod"},{"description":"This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf ( local lines).","names":["--auth-local= authmethod"],"signature":"--auth-local= authmethod"},{"description":"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 data directory later by the same variable.","names":["-D directory","--pgdata= directory"],"signature":"-D directory --pgdata= directory"},{"description":"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 PostgreSQL server are described in Section 23.3.1 . By default, the template database encoding is derived from the locale. If --no-locale is specified (or equivalently, if the locale is C or POSIX ), then the default is UTF8 for the ICU provider and SQL_ASCII for the libc provider.","names":["-E encoding","--encoding= encoding"],"signature":"-E encoding --encoding= encoding"},{"description":"Allows users in the same group as the cluster owner to read all cluster files created by initdb . This option is ignored on Windows as it does not support POSIX -style group permissions.","names":["-g","--allow-group-access"],"signature":"-g --allow-group-access"},{"description":"Specifies the ICU locale when the ICU provider is used. Locale support is described in Section 23.1 .","names":["--icu-locale= locale"],"signature":"--icu-locale= locale"},{"description":"Specifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only.","names":["--icu-rules= rules"],"signature":"--icu-rules= rules"},{"description":"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 --no-data-checksums to disable checksums. 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 pg_stat_database view. See Section 28.2 for details.","names":["-k","--data-checksums"],"signature":"-k --data-checksums"},{"description":"Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in. Locale support is described in Section 23.1 . If --locale-provider is builtin , --locale or --builtin-locale must be specified and set to C , C.UTF-8 or PG_UNICODE_FAST .","names":["--locale= locale"],"signature":"--locale= locale"},{"description":"Like --locale , but only sets the locale in the specified category.","names":["--lc-collate= locale","--lc-ctype= locale","--lc-messages= locale","--lc-monetary= locale","--lc-numeric= locale","--lc-time= locale"],"signature":"--lc-collate= locale --lc-ctype= locale --lc-messages= locale --lc-monetary= locale --lc-numeric= locale --lc-time= locale"},{"description":"Equivalent to --locale=C .","names":["--no-locale"],"signature":"--no-locale"},{"description":"Specifies the locale name when the builtin provider is used. Locale support is described in Section 23.1 .","names":["--builtin-locale= locale"],"signature":"--builtin-locale= locale"},{"description":"This option sets the locale provider for databases created in the new cluster. It can be overridden in the CREATE DATABASE command when new databases are subsequently created. The default is libc (see Section 23.1.4 ).","names":["--locale-provider={ builtin | libc | icu }"],"signature":"--locale-provider={ builtin | libc | icu }"},{"description":"Do not enable data checksums.","names":["--no-data-checksums"],"signature":"--no-data-checksums"},{"description":"Makes initdb read the bootstrap superuser's password from a file. The first line of the file is taken as the password.","names":["--pwfile= filename"],"signature":"--pwfile= filename"},{"description":"Sets the default text search configuration. See default_text_search_config for further information.","names":["-T config","--text-search-config= config"],"signature":"-T config --text-search-config= config"},{"description":"Sets the user name of the bootstrap superuser . This defaults to the name of the operating-system user running initdb .","names":["-U username","--username= username"],"signature":"-U username --username= username"},{"description":"Makes initdb prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.","names":["-W","--pwprompt"],"signature":"-W --pwprompt"},{"description":"This option specifies the directory where the write-ahead log should be stored.","names":["-X directory","--waldir= directory"],"signature":"-X directory --waldir= directory"},{"description":"Set the 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. 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.","names":["--wal-segsize= size"],"signature":"--wal-segsize= size"},{"description":"Forcibly set the server parameter name to value during initdb , and also install that setting in the generated postgresql.conf 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.","names":["-c name = value","--set name = value"],"signature":"-c name = value --set name = value"},{"description":"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 initdb uses to create the catalog tables. This option generates a tremendous amount of extremely boring output.","names":["-d","--debug"],"signature":"-d --debug"},{"description":"Run the bootstrap backend with the debug_discard_caches=1 option. This takes a very long time and is only of use for deep debugging.","names":["--discard-caches"],"signature":"--discard-caches"},{"description":"Specifies where initdb 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.","names":["-L directory"],"signature":"-L directory"},{"description":"By default, when initdb 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.","names":["-n","--no-clean"],"signature":"-n --no-clean"},{"description":"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 option is useful for testing, but should not be used when creating a production installation.","names":["-N","--no-sync"],"signature":"-N --no-sync"},{"description":"By default, initdb safely writes all database files to disk. This option instructs initdb to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the base subdirectory and any other tablespace directories. Other files, such as those in pg_wal and pg_xact , will still be synchronized unless the --no-sync option is also specified. Note that if --no-sync-data-files is used in conjunction with --sync-method=syncfs , some or all of the aforementioned files and directories will be synchronized because syncfs processes entire file systems. This option is primarily intended for internal use by tools that separately ensure the skipped files are synchronized to disk.","names":["--no-sync-data-files"],"signature":"--no-sync-data-files"},{"description":"By default, initdb 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 initdb in platform-specific behavior, where those instructions are likely to be incorrect.","names":["--no-instructions"],"signature":"--no-instructions"},{"description":"Show internal settings and exit, without doing anything else. This can be used to debug the initdb installation.","names":["-s","--show"],"signature":"-s --show"},{"description":"When set to fsync , which is the default, initdb 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. On Linux, syncfs 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 recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used.","names":["--sync-method= method"],"signature":"--sync-method= method"},{"description":"Safely write all database files to disk and exit. This does not perform any of the normal initdb operations. Generally, this option is useful for ensuring reliable recovery after changing fsync from off to on .","names":["-S","--sync-only"],"signature":"-S --sync-only"},{"description":"Print the initdb version and exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Show help about initdb command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help"}],"synopsis":["initdb [ option ...] [ --pgdata | -D ] directory"]},"comparison_hash":"9d023384fdab35b09900cd14ac90a5dbe44bace6659e36877cd11b68fb2bd76e","description":["initdb — create a new PostgreSQL database cluster"],"description_zh":"描述 initdb 创建一个新的 PostgreSQL 数据库集簇 。 创建数据库集簇包括创建用于存放集簇数据的 目录 ，生成共享系统目录表（属于整个集簇而不是某个特定数据库的表），以及创建 postgres 、 template1 和 template0 数据库。 postgres 数据库是一个默认数据库，供用户、工具程序和第三方应用程序使用。 template1 和 template0 用作后续 CREATE DATABASE 命令复制的源数据库。 template0 不应被修改，但可以向 template1 中添加对象，这些对象默认会被复制到以后创建的数据库中。更多细节见 第 22.3 节 。 虽然 initdb 会尝试创建指定的数据目录，但如果所需数据目录的父目录归 root 所有，它可能没有足够的权限。要在这种环境中初始化，可先由 root 创建一个空的数据目录，然后用 chown 将该目录的所有权赋予数据库用户账户，再用 su 切换为该数据库用户来运行 initdb 。 initdb 必须以将拥有服务器进程的用户身份运行，因为服务器需要访问 initdb 创建的文件和目录。由于服务器不能以 root 身份运行，因此也绝不能以 root 身份运行 initdb 。（实际上它会拒绝这样做。） 出于安全原因， initdb 创建的新集簇默认只有集簇拥有者可以访问。 --allow-group-access 选项允许与集簇拥有者同组的任何用户读取集簇中的文件。这对由非特权用户执行备份很有用。 initdb 会初始化数据库集簇的默认区域设置和字符集编码。这些设置也可以在创建每个数据库时分别设置。 initdb 为模板数据库确定这些设置，它们将作为所有其他数据库的默认值。 默认情况下， initdb 使用 libc 区域设置提供程序（见 第 23.1.4 节 ）。 libc 区域设置提供程序会从环境中获取区域设置，并根据区域设置确定编码。 要为集簇选择不同的区域设置，请使用 --locale 。此外还有单独的 --lc-* 和 --icu-locale 选项（见下文），","description_zh_html":"\u003cp\u003e命令行工具 initdb [ option ...] [ --pgdata | -D ] directory。\u003c/p\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 创建一个新的 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\n\u003ca class=\"glossterm\" href=\"/zh/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\"\u003e\u003cem class=\"glossterm\"\u003e\u003c/em\u003e\u003c/a\u003e\u003cem class=\"glossterm\"\u003e\u003ca class=\"glossterm\" href=\"/zh/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\"\u003e数据库集簇\u003c/a\u003e\u003c/em\u003e。\n  \u003c/p\u003e\u003cp\u003e\n   创建数据库集簇包括创建用于存放集簇数据的\u003ca class=\"glossterm\" href=\"/zh/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\"\u003e\u003cem class=\"glossterm\"\u003e\u003c/em\u003e\u003c/a\u003e\u003cem class=\"glossterm\"\u003e\u003ca class=\"glossterm\" href=\"/zh/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\"\u003e目录\u003c/a\u003e\u003c/em\u003e，生成共享系统目录表（属于整个集簇而不是某个特定数据库的表），以及创建\n   \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e、\u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e 和\n   \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e 数据库。\u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e\n   数据库是一个默认数据库，供用户、工具程序和第三方应用程序使用。\u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e 和 \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e\n   用作后续 \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e 命令复制的源数据库。\u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e 不应被修改，但可以向\n   \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e 中添加对象，这些对象默认会被复制到以后创建的数据库中。更多细节见\u003ca class=\"xref\" href=\"/zh/docs/18/manage-ag-templatedbs.html\"\u003e第 22.3 节\u003c/a\u003e。\n  \u003c/p\u003e\u003cp\u003e\n   虽然 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会尝试创建指定的数据目录，但如果所需数据目录的父目录归\n   root 所有，它可能没有足够的权限。要在这种环境中初始化，可先由 root 创建一个空的数据目录，然后用 \u003ccode class=\"command\"\u003echown\u003c/code\u003e 将该目录的所有权赋予数据库用户账户，再用\n   \u003ccode class=\"command\"\u003esu\u003c/code\u003e 切换为该数据库用户来运行 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e。\n  \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 必须以将拥有服务器进程的用户身份运行，因为服务器需要访问\n   \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 创建的文件和目录。由于服务器不能以 root 身份运行，因此也绝不能以 root 身份运行 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e。（实际上它会拒绝这样做。）\n  \u003c/p\u003e\u003cp\u003e\n   出于安全原因，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 创建的新集簇默认只有集簇拥有者可以访问。\u003ccode class=\"option\"\u003e--allow-group-access\u003c/code\u003e 选项允许与集簇拥有者同组的任何用户读取集簇中的文件。这对由非特权用户执行备份很有用。\n  \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会初始化数据库集簇的默认区域设置和字符集编码。这些设置也可以在创建每个数据库时分别设置。\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 为模板数据库确定这些设置，它们将作为所有其他数据库的默认值。\n  \u003c/p\u003e\u003cp\u003e\n   默认情况下，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 使用 \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e 区域设置提供程序（见\u003ca class=\"xref\" href=\"/zh/docs/18/locale.html#LOCALE-PROVIDERS\"\u003e第 23.1.4 节\u003c/a\u003e）。\u003ccode class=\"literal\"\u003elibc\u003c/code\u003e 区域设置提供程序会从环境中获取区域设置，并根据区域设置确定编码。\n  \u003c/p\u003e\u003cp\u003e\n   要为集簇选择不同的区域设置，请使用 \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e。此外还有单独的\n   \u003ccode class=\"option\"\u003e--lc-*\u003c/code\u003e 和 \u003ccode class=\"option\"\u003e--icu-locale\u003c/code\u003e 选项（见下文），用于为各个区域设置类别设置值。请注意，不同区域设置类别之间若设置不一致，可能产生不合理的结果，因此应谨慎使用。\n  \u003c/p\u003e\u003cp\u003e\n   另一种方式是指定 \u003ccode class=\"literal\"\u003e--locale-provider=icu\u003c/code\u003e，让 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e\n   使用 ICU 库提供区域设置服务。服务器必须在构建时启用 ICU 支持。要选择具体要应用的 ICU\n   区域设置 ID，请使用 \u003ccode class=\"option\"\u003e--icu-locale\u003c/code\u003e。请注意，出于实现原因以及对旧代码的支持，在使用 ICU 区域设置提供程序时，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 仍会选择并初始化 libc 区域设置。\n  \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 运行时会打印出它选择的区域设置。如果有复杂需求或者指定了多个选项，建议检查结果是否符合预期。\n  \u003c/p\u003e\u003cp\u003e\n   有关区域设置的更多细节见\u003ca class=\"xref\" href=\"/zh/docs/18/locale.html\"\u003e第 23.1 节\u003c/a\u003e。\n  \u003c/p\u003e\u003cp\u003e\n   要修改默认编码，请使用 \u003ccode class=\"option\"\u003e--encoding\u003c/code\u003e。更多细节见\u003ca class=\"xref\" href=\"/zh/docs/18/multibyte.html\"\u003e第 23.3 节\u003c/a\u003e。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e选项\u003c/h2\u003e\u003cp\u003e\n\u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-A \u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        该选项指定 \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e 中本地用户默认使用的认证方法（\u003ccode class=\"literal\"\u003ehost\u003c/code\u003e 和 \u003ccode class=\"literal\"\u003elocal\u003c/code\u003e 行）。有效值概览见\u003ca class=\"xref\" href=\"/zh/docs/18/auth-pg-hba-conf.html\"\u003e第 20.1 节\u003c/a\u003e。\n       \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会使用指定的认证方法预填充 \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e\n        条目，既用于非复制连接，也用于复制连接。\n       \u003c/p\u003e\u003cp\u003e\n        除非信任系统上的所有本地用户，否则不要使用 \u003ccode class=\"literal\"\u003etrust\u003c/code\u003e。为了便于安装，默认使用 \u003ccode class=\"literal\"\u003etrust\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth-host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        该选项指定 \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e 中本地用户通过 TCP/IP 连接时（\u003ccode class=\"literal\"\u003ehost\u003c/code\u003e 行）使用的认证方法。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth-local=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        该选项指定 \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e 中本地用户通过 Unix 域套接字连接时（\u003ccode class=\"literal\"\u003elocal\u003c/code\u003e 行）使用的认证方法。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        该选项指定数据库集簇应存放的目录。这是 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 所需的唯一信息，但也可以通过设置 \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e 环境变量来省去显式写出它；这通常更方便，因为数据库服务器（\u003ccode class=\"command\"\u003epostgres\u003c/code\u003e）之后也可以通过同一变量找到数据目录。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E \u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--encoding=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        选择模板数据库的编码。这也将成为以后创建的任何数据库的默认编码，除非在创建时覆盖它。\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 服务器支持的字符集见\u003ca class=\"xref\" href=\"/zh/docs/18/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\"\u003e第 23.3.1 节\u003c/a\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        默认情况下，模板数据库的编码从区域设置派生。如果指定了 \u003ca class=\"xref\" href=\"/zh/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE\"\u003e\u003ccode class=\"option\"\u003e--no-locale\u003c/code\u003e\u003c/a\u003e（或者等价地，区域设置为\n        \u003ccode class=\"literal\"\u003eC\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003ePOSIX\u003c/code\u003e），那么 ICU 提供程序的默认值为\n        \u003ccode class=\"literal\"\u003eUTF8\u003c/code\u003e，而 \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e 提供程序的默认值为\n        \u003ccode class=\"literal\"\u003eSQL_ASCII\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-g\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--allow-group-access\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        允许与集簇拥有者同组的用户读取由 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 创建的所有集簇文件。该选项在 \u003cspan class=\"productname\"\u003eWindows\u003c/span\u003e 上会被忽略，因为它不支持\n        \u003cacronym class=\"acronym\"\u003ePOSIX\u003c/acronym\u003e 风格的组权限。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--icu-locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        当使用 ICU 提供程序时，指定 ICU 区域设置。区域设置支持见\u003ca class=\"xref\" href=\"/zh/docs/18/locale.html\"\u003e第 23.1 节\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--icu-rules=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erules\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定附加的排序规则，以定制默认排序规则的行为。该选项仅支持 ICU。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-k\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        对数据页启用校验和，以帮助检测原本会悄无声息发生的、由 I/O 系统导致的损坏。该项默认启用；使用 \u003ca class=\"xref\" href=\"/zh/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS\"\u003e\u003ccode class=\"option\"\u003e--no-data-checksums\u003c/code\u003e\u003c/a\u003e 可禁用校验和。\n       \u003c/p\u003e\u003cp\u003e\n        启用校验和可能会带来小幅性能损失。如果启用，就会为所有数据库中的所有对象计算校验和。所有校验和失败都会在\n        \u003ca class=\"link\" href=\"/zh/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\"\u003e\n\u003ccode class=\"structname\"\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e 视图中报告。详见\u003ca class=\"xref\" href=\"/zh/docs/18/checksums.html\"\u003e第 28.2 节\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设置数据库集簇的默认区域设置。如果未指定该选项，区域设置将继承自\n        \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 运行时所在的环境。区域设置支持见\u003ca class=\"xref\" href=\"/zh/docs/18/locale.html\"\u003e第 23.1 节\u003c/a\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        如果 \u003ccode class=\"option\"\u003e--locale-provider\u003c/code\u003e 为 \u003ccode class=\"literal\"\u003ebuiltin\u003c/code\u003e，则必须指定 \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e 或 \u003ccode class=\"option\"\u003e--builtin-locale\u003c/code\u003e，并将其设置为 \u003ccode class=\"literal\"\u003eC\u003c/code\u003e、\u003ccode class=\"literal\"\u003eC.UTF-8\u003c/code\u003e 或\n        \u003ccode class=\"literal\"\u003ePG_UNICODE_FAST\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-collate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-ctype=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-messages=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-monetary=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-numeric=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-time=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        类似于 \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e，但只在指定的类别中设置区域设置。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-locale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        等价于 \u003ccode class=\"option\"\u003e--locale=C\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--builtin-locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        当使用 builtin 提供程序时，指定区域设置名称。区域设置支持见\u003ca class=\"xref\" href=\"/zh/docs/18/locale.html\"\u003e第 23.1 节\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--locale-provider={\u003ccode class=\"literal\"\u003ebuiltin\u003c/code\u003e|\u003ccode class=\"literal\"\u003elibc\u003c/code\u003e|\u003ccode class=\"literal\"\u003eicu\u003c/code\u003e}\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        该选项设置新集簇中创建的数据库所使用的区域设置提供程序。后续创建新数据库时，可以在 \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e 命令中覆盖它。默认值为\n        \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e（见\u003ca class=\"xref\" href=\"/zh/docs/18/locale.html#LOCALE-PROVIDERS\"\u003e第 23.1.4 节\u003c/a\u003e）。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不启用数据校验和。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pwfile=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        使 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 从文件中读取引导超级用户的密码。文件的第一行会被当作密码。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--text-search-config=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设置默认文本检索配置。更多信息见 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG\"\u003edefault_text_search_config\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设置\u003ca class=\"glossterm\" href=\"/zh/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\"\u003e\u003cem class=\"glossterm\"\u003e\u003c/em\u003e\u003c/a\u003e\u003cem class=\"glossterm\"\u003e\u003ca class=\"glossterm\" href=\"/zh/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\"\u003e引导超级用户\u003c/a\u003e\u003c/em\u003e的用户名。默认值是运行 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 的操作系统用户名。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pwprompt\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        使 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 提示输入要赋给引导超级用户的密码。如果不打算使用密码认证，这一点并不重要。否则，在设置密码之前将无法使用密码认证。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--waldir=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        该选项指定预写式日志（WAL）应存放的目录。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-segsize=\u003cem class=\"replaceable\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设置 \u003cem class=\"firstterm\"\u003eWAL 段大小\u003c/em\u003e，单位为兆字节。这是 WAL 日志中每个单独文件的大小。默认大小为 16 兆字节。该值必须是 1 到 1024（兆字节）之间的 2 的幂。此选项只能在初始化期间设置，以后不能更改。\n       \u003c/p\u003e\u003cp\u003e\n        调整该大小可能有助于控制 WAL 日志传送或归档的粒度。此外，在 WAL 量很大的数据库中，每个目录中的 WAL 文件数量可能会成为性能和管理问题。增大 WAL 文件大小会减少 WAL 文件数量。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n    还提供了其他一些较少使用的选项：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--set \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 期间，强制将服务器参数 \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\n        设为 \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e，并把该设置写入生成的\n        \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 文件，以便在今后的服务器运行中生效。该选项可指定多次，以设置多个参数。它主要用于默认参数下服务器根本无法启动的环境。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        打印引导后端的调试输出，以及少量普通用户通常不感兴趣的其他消息。引导后端是\n        \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 用来创建系统目录表的程序。该选项会产生大量极其乏味的输出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--discard-caches\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        使用 \u003ccode class=\"literal\"\u003edebug_discard_caches=1\u003c/code\u003e 选项运行引导后端。这会花费很长时间，只对深度调试有用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 初始化数据库集簇时应到哪里查找其输入文件。通常不需要这样做。若需要显式指定其位置，系统会提示。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        默认情况下，如果 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 发现某个错误使其无法完整创建数据库集簇，就会删除它在发现无法完成任务之前可能已创建的所有文件。该选项会禁止这种清理，因此对调试有用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        默认情况下，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会等待所有文件都安全写入磁盘。该选项使\n        \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 在不等待的情况下返回，速度更快，但这意味着如果后续操作系统崩溃，数据目录可能会损坏。通常，该选项适用于测试，但不应用于创建生产环境安装。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync-data-files\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        默认情况下，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会将所有数据库文件安全地写入磁盘。该选项指示 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 跳过同步各个数据库目录中的所有文件、这些数据库目录本身以及表空间目录，也就是 \u003ccode class=\"filename\"\u003ebase\u003c/code\u003e 子目录中的所有内容和任何其他表空间目录。其他文件，例如 \u003ccode class=\"literal\"\u003epg_wal\u003c/code\u003e 和 \u003ccode class=\"literal\"\u003epg_xact\u003c/code\u003e 中的文件，仍会被同步，除非也指定了 \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        请注意，如果 \u003ccode class=\"option\"\u003e--no-sync-data-files\u003c/code\u003e 与\n        \u003ccode class=\"option\"\u003e--sync-method=syncfs\u003c/code\u003e 一起使用，上述部分或全部文件与目录仍会被同步，因为 \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e 处理的是整个文件系统。\n       \u003c/p\u003e\u003cp\u003e\n        该选项主要供那些会另行确保这些被跳过文件已同步到磁盘的工具在内部使用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-instructions\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        默认情况下，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会在其输出末尾写出如何启动集簇的说明。该选项会省略这些说明。它主要供那些对 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 进行平台特定封装的工具使用，因为在这种情况下那些说明很可能并不正确。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--show\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        显示内部设置并退出，不执行其他操作。可用于调试 \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e 的安装。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设为 \u003ccode class=\"literal\"\u003efsync\u003c/code\u003e（默认值）时，\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 会递归打开并同步数据目录中的所有文件。查找文件时会跟随 WAL 目录和每个已配置表空间的符号链接。\n       \u003c/p\u003e\u003cp\u003e\n        在 Linux 上，也可以改用 \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e，请求操作系统同步包含数据目录、WAL 文件以及每个表空间的整个文件系统。使用 \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e 时需注意的事项见 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\"\u003erecovery_init_sync_method\u003c/a\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        使用 \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e 时，该选项不起作用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将所有数据库文件安全地写入磁盘并退出。这不会执行任何常规的\n        \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e 操作。通常，该选项可用于在将 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-wal.html#GUC-FSYNC\"\u003efsync\u003c/a\u003e 从 \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e 改为 \u003ccode class=\"literal\"\u003eon\u003c/code\u003e 后，确保能够可靠恢复。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n    其他选项：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       打印 \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e 版本并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       显示有关 \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e 命令行参数的帮助并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/app-initdb.html\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","environment":[{"description":"Specifies the directory where the database cluster is to be stored; can be overridden using the -D option.","name":"PGDATA"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Specifies the default time zone of the created database cluster. The value should be a full time zone name (see Section 8.5.3 ).","name":"TZ"}],"facts":[{"label":"Documented executable","value":"initdb"},{"label":"Executable version","value":"18.6"},{"label":"Reference inventory","value":"Server applications"},{"label":"Option definition groups","value":"34"}],"facts_zh":[{"label":"手册中的可执行程序","value":"initdb"},{"label":"程序版本","value":"18.6"},{"label":"参考清单","value":"服务端程序"},{"label":"选项定义组","value":"34"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-INITDB\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003einitdb — create a new \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.3.4.1\"\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [ \u003ccode class=\"option\"\u003e--pgdata\u003c/code\u003e | \u003ccode class=\"option\"\u003e-D\u003c/code\u003e ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-INITDB-1\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e creates a new \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e \u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\"\u003e\u003c/a\u003e\u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\" title=\"Database cluster\"\u003edatabase cluster\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eCreating a database cluster consists of creating the \u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\"\u003e\u003c/a\u003e\u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\" title=\"Data directory\"\u003edirectories\u003c/a\u003e 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 \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e, \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e databases. The \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e database is a default database meant for use by users, utilities and third party applications. \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e and \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e are meant as source databases to be copied by later \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e commands. \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e should never be modified, but you can add objects to \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, which by default will be copied into databases created later. See \u003ca class=\"xref\" href=\"/docs/18/manage-ag-templatedbs.html\" title=\"22.3. Template Databases\"\u003eSection 22.3\u003c/a\u003e for more details.\u003c/p\u003e\n\u003cp\u003eAlthough \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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 \u003ccode class=\"command\"\u003echown\u003c/code\u003e to assign ownership of that directory to the database user account, then \u003ccode class=\"command\"\u003esu\u003c/code\u003e to become the database user to run \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e creates. Since the server cannot be run as root, you must not run \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e as root either. (It will in fact refuse to do so.)\u003c/p\u003e\n\u003cp\u003eFor security reasons the new cluster created by \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will only be accessible by the cluster owner by default. The \u003ccode class=\"option\"\u003e--allow-group-access\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e initializes the database cluster's default locale and character set encoding. These can also be set separately for each database when it is created. \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e determines those settings for the template databases, which will serve as the default for all other databases.\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e uses the locale provider \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e (see \u003ca class=\"xref\" href=\"/docs/18/locale.html#LOCALE-PROVIDERS\" title=\"23.1.4. Locale Providers\"\u003eSection 23.1.4\u003c/a\u003e). The \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e locale provider takes the locale settings from the environment, and determines the encoding from the locale settings.\u003c/p\u003e\n\u003cp\u003eTo choose a different locale for the cluster, use the option \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e. There are also individual options \u003ccode class=\"option\"\u003e--lc-*\u003c/code\u003e and \u003ccode class=\"option\"\u003e--icu-locale\u003c/code\u003e (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.\u003c/p\u003e\n\u003cp\u003eAlternatively, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e can use the ICU library to provide locale services by specifying \u003ccode class=\"literal\"\u003e--locale-provider=icu\u003c/code\u003e. The server must be built with ICU support. To choose the specific ICU locale ID to apply, use the option \u003ccode class=\"option\"\u003e--icu-locale\u003c/code\u003e. Note that for implementation reasons and to support legacy code, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will still select and initialize libc locale settings when the ICU locale provider is used.\u003c/p\u003e\n\u003cp\u003eWhen \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eMore details about locale settings can be found in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eTo alter the default encoding, use the \u003ccode class=\"option\"\u003e--encoding\u003c/code\u003e. More details can be found in \u003ca class=\"xref\" href=\"/docs/18/multibyte.html\" title=\"23.3. Character Set Support\"\u003eSection 23.3\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-A \u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the default authentication method for local users used in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e (\u003ccode class=\"literal\"\u003ehost\u003c/code\u003e and \u003ccode class=\"literal\"\u003elocal\u003c/code\u003e lines). See \u003ca class=\"xref\" href=\"/docs/18/auth-pg-hba-conf.html\" title=\"20.1. The pg_hba.conf File\"\u003eSection 20.1\u003c/a\u003e for an overview of valid values.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will prepopulate \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e entries using the specified authentication method for non-replication as well as replication connections.\u003c/p\u003e\n\u003cp\u003eDo not use \u003ccode class=\"literal\"\u003etrust\u003c/code\u003e unless you trust all local users on your system. \u003ccode class=\"literal\"\u003etrust\u003c/code\u003e is the default for ease of installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth-host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the authentication method for local users via TCP/IP connections used in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e (\u003ccode class=\"literal\"\u003ehost\u003c/code\u003e lines).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH-LOCAL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth-local=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the authentication method for local users via Unix-domain socket connections used in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e (\u003ccode class=\"literal\"\u003elocal\u003c/code\u003e lines).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PGDATA\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the directory where the database cluster should be stored. This is the only information required by \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e, but you can avoid writing it by setting the \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e environment variable, which can be convenient since the database server (\u003ccode class=\"command\"\u003epostgres\u003c/code\u003e) can find the data directory later by the same variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-ENCODING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E \u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--encoding=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSelects 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 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server are described in \u003ca class=\"xref\" href=\"/docs/18/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1. Supported Character Sets\"\u003eSection 23.3.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eBy default, the template database encoding is derived from the locale. If \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE\"\u003e\u003ccode class=\"option\"\u003e--no-locale\u003c/code\u003e\u003c/a\u003e is specified (or equivalently, if the locale is \u003ccode class=\"literal\"\u003eC\u003c/code\u003e or \u003ccode class=\"literal\"\u003ePOSIX\u003c/code\u003e), then the default is \u003ccode class=\"literal\"\u003eUTF8\u003c/code\u003e for the ICU provider and \u003ccode class=\"literal\"\u003eSQL_ASCII\u003c/code\u003e for the \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e provider.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ALLOW-GROUP-ACCESS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-g\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--allow-group-access\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAllows users in the same group as the cluster owner to read all cluster files created by \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e. This option is ignored on \u003cspan class=\"productname\"\u003eWindows\u003c/span\u003e as it does not support POSIX-style group permissions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ICU-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--icu-locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the ICU locale when the ICU provider is used. Locale support is described in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ICU-RULES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--icu-rules=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erules\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-DATA-CHECKSUMS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-k\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. This is enabled by default; use \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS\"\u003e\u003ccode class=\"option\"\u003e--no-data-checksums\u003c/code\u003e\u003c/a\u003e to disable checksums.\u003c/p\u003e\n\u003cp\u003eEnabling 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 \u003ca class=\"link\" href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\" title=\"27.2.17. pg_stat_database\"\u003e\u003ccode class=\"structname\"\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e view. See \u003ca class=\"xref\" href=\"/docs/18/checksums.html\" title=\"28.2. Data Checksums\"\u003eSection 28.2\u003c/a\u003e for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e runs in. Locale support is described in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"option\"\u003e--locale-provider\u003c/code\u003e is \u003ccode class=\"literal\"\u003ebuiltin\u003c/code\u003e, \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e or \u003ccode class=\"option\"\u003e--builtin-locale\u003c/code\u003e must be specified and set to \u003ccode class=\"literal\"\u003eC\u003c/code\u003e, \u003ccode class=\"literal\"\u003eC.UTF-8\u003c/code\u003e or \u003ccode class=\"literal\"\u003ePG_UNICODE_FAST\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LC-COLLATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-collate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-ctype=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-messages=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-monetary=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-numeric=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-time=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLike \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e, but only sets the locale in the specified category.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-locale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEquivalent to \u003ccode class=\"option\"\u003e--locale=C\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-BUILTIN-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--builtin-locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the locale name when the builtin provider is used. Locale support is described in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LOCALE-PROVIDER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--locale-provider={\u003ccode class=\"literal\"\u003ebuiltin\u003c/code\u003e|\u003ccode class=\"literal\"\u003elibc\u003c/code\u003e|\u003ccode class=\"literal\"\u003eicu\u003c/code\u003e}\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option sets the locale provider for databases created in the new cluster. It can be overridden in the \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e command when new databases are subsequently created. The default is \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e (see \u003ca class=\"xref\" href=\"/docs/18/locale.html#LOCALE-PROVIDERS\" title=\"23.1.4. Locale Providers\"\u003eSection 23.1.4\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-NO-DATA-CHECKSUMS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not enable data checksums.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PWFILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pwfile=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMakes \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e read the bootstrap superuser's password from a file. The first line of the file is taken as the password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-TEXT-SEARCH-CONFIG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--text-search-config=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the default text search configuration. See \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG\"\u003edefault_text_search_config\u003c/a\u003e for further information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-USERNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the user name of the \u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\"\u003e\u003c/a\u003e\u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\" title=\"Bootstrap superuser\"\u003ebootstrap superuser\u003c/a\u003e. This defaults to the name of the operating-system user running \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PWPROMPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pwprompt\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMakes \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-WALDIR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--waldir=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the directory where the write-ahead log should be stored.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-WAL-SEGSIZE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-segsize=\u003cem class=\"replaceable\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the \u003cem class=\"firstterm\"\u003eWAL segment size\u003c/em\u003e, 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.\u003c/p\u003e\n\u003cp\u003eIt 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther, less commonly used, options are also available:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--set \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForcibly set the server parameter \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e during \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e, and also install that setting in the generated \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-DEBUG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint debugging output from the bootstrap backend and a few other messages of lesser interest for the general public. The bootstrap backend is the program \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e uses to create the catalog tables. This option generates a tremendous amount of extremely boring output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-DISCARD-CACHES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--discard-caches\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun the bootstrap backend with the \u003ccode class=\"literal\"\u003edebug_discard_caches=1\u003c/code\u003e option. This takes a very long time and is only of use for deep debugging.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-L\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies where \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-CLEAN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, when \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-SYNC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will wait for all files to be written safely to disk. This option causes \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-SYNC-DATA-FILES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync-data-files\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e safely writes all database files to disk. This option instructs \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the \u003ccode class=\"filename\"\u003ebase\u003c/code\u003e subdirectory and any other tablespace directories. Other files, such as those in \u003ccode class=\"literal\"\u003epg_wal\u003c/code\u003e and \u003ccode class=\"literal\"\u003epg_xact\u003c/code\u003e, will still be synchronized unless the \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e option is also specified.\u003c/p\u003e\n\u003cp\u003eNote that if \u003ccode class=\"option\"\u003e--no-sync-data-files\u003c/code\u003e is used in conjunction with \u003ccode class=\"option\"\u003e--sync-method=syncfs\u003c/code\u003e, some or all of the aforementioned files and directories will be synchronized because \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e processes entire file systems.\u003c/p\u003e\n\u003cp\u003eThis option is primarily intended for internal use by tools that separately ensure the skipped files are synchronized to disk.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-INSTRUCTIONS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-instructions\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e in platform-specific behavior, where those instructions are likely to be incorrect.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SHOW\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--show\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow internal settings and exit, without doing anything else. This can be used to debug the \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SYNC-METHOD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode class=\"literal\"\u003efsync\u003c/code\u003e, which is the default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eOn Linux, \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e 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 \u003ca class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\"\u003erecovery_init_sync_method\u003c/a\u003e for information about the caveats to be aware of when using \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option has no effect when \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SYNC-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSafely write all database files to disk and exit. This does not perform any of the normal \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e operations. Generally, this option is useful for ensuring reliable recovery after changing \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-FSYNC\"\u003efsync\u003c/a\u003e from \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-OPTION-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-PGDATA\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the directory where the database cluster is to be stored; can be overridden using the \u003ccode class=\"option\"\u003e-D\u003c/code\u003e option.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-PG-COLOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-TZ\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eTZ\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the default time zone of the created database cluster. The value should be a full time zone name (see \u003ca class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-TIMEZONES\" title=\"8.5.3. Time Zones\"\u003eSection 8.5.3\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e can also be invoked via \u003ccode class=\"command\"\u003epg_ctl initdb\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.9\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pg-ctl.html\" title=\"pg_ctl\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/auth-pg-hba-conf.html\" title=\"20.1. The pg_hba.conf File\"\u003eSection 20.1\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"app-initdb.html","options":[{"description":"This option specifies the default authentication method for local users used in pg_hba.conf ( host and local lines). See Section 20.1 for an overview of valid values. initdb will prepopulate 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.","names":["-A authmethod","--auth= authmethod"],"signature":"-A authmethod --auth= authmethod","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH","summary":"This option specifies the default authentication method for local users used in pg_hba.conf ( host and local lines). See Section 20.1 for an overview of valid values."},{"description":"This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf ( host lines).","names":["--auth-host= authmethod"],"signature":"--auth-host= authmethod","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-HOST","summary":"This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf ( host lines)."},{"description":"This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf ( local lines).","names":["--auth-local= authmethod"],"signature":"--auth-local= authmethod","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-LOCAL","summary":"This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf ( local lines)."},{"description":"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 data directory later by the same variable.","names":["-D directory","--pgdata= directory"],"signature":"-D directory --pgdata= directory","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PGDATA","summary":"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 data directory later by the same variable."},{"description":"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 PostgreSQL server are described in Section 23.3.1 . By default, the template database encoding is derived from the locale. If --no-locale is specified (or equivalently, if the locale is C or POSIX ), then the default is UTF8 for the ICU provider and SQL_ASCII for the libc provider.","names":["-E encoding","--encoding= encoding"],"signature":"-E encoding --encoding= encoding","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-ENCODING","summary":"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 PostgreSQL server are described in Section 23.3.1 ."},{"description":"Allows users in the same group as the cluster owner to read all cluster files created by initdb . This option is ignored on Windows as it does not support POSIX -style group permissions.","names":["-g","--allow-group-access"],"signature":"-g --allow-group-access","source_url":"/docs/18/app-initdb.html#APP-INITDB-ALLOW-GROUP-ACCESS","summary":"Allows users in the same group as the cluster owner to read all cluster files created by initdb . This option is ignored on Windows as it does not support POSIX -style group permissions."},{"description":"Specifies the ICU locale when the ICU provider is used. Locale support is described in Section 23.1 .","names":["--icu-locale= locale"],"signature":"--icu-locale= locale","source_url":"/docs/18/app-initdb.html#APP-INITDB-ICU-LOCALE","summary":"Specifies the ICU locale when the ICU provider is used. Locale support is described in Section 23.1 ."},{"description":"Specifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only.","names":["--icu-rules= rules"],"signature":"--icu-rules= rules","source_url":"/docs/18/app-initdb.html#APP-INITDB-ICU-RULES","summary":"Specifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only."},{"description":"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 --no-data-checksums to disable checksums. 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 pg_stat_database view. See Section 28.2 for details.","names":["-k","--data-checksums"],"signature":"-k --data-checksums","source_url":"/docs/18/app-initdb.html#APP-INITDB-DATA-CHECKSUMS","summary":"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 --no-data-checksums to disable checksums."},{"description":"Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in. Locale support is described in Section 23.1 . If --locale-provider is builtin , --locale or --builtin-locale must be specified and set to C , C.UTF-8 or PG_UNICODE_FAST .","names":["--locale= locale"],"signature":"--locale= locale","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE","summary":"Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in. Locale support is described in Section 23.1 ."},{"description":"Like --locale , but only sets the locale in the specified category.","names":["--lc-collate= locale","--lc-ctype= locale","--lc-messages= locale","--lc-monetary= locale","--lc-numeric= locale","--lc-time= locale"],"signature":"--lc-collate= locale --lc-ctype= locale --lc-messages= locale --lc-monetary= locale --lc-numeric= locale --lc-time= locale","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LC-COLLATE","summary":"Like --locale , but only sets the locale in the specified category."},{"description":"Equivalent to --locale=C .","names":["--no-locale"],"signature":"--no-locale","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE","summary":"Equivalent to --locale=C ."},{"description":"Specifies the locale name when the builtin provider is used. Locale support is described in Section 23.1 .","names":["--builtin-locale= locale"],"signature":"--builtin-locale= locale","source_url":"/docs/18/app-initdb.html#APP-INITDB-BUILTIN-LOCALE","summary":"Specifies the locale name when the builtin provider is used. Locale support is described in Section 23.1 ."},{"description":"This option sets the locale provider for databases created in the new cluster. It can be overridden in the CREATE DATABASE command when new databases are subsequently created. The default is libc (see Section 23.1.4 ).","names":["--locale-provider={ builtin | libc | icu }"],"signature":"--locale-provider={ builtin | libc | icu }","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE-PROVIDER","summary":"This option sets the locale provider for databases created in the new cluster. It can be overridden in the CREATE DATABASE command when new databases are subsequently created. The default is libc (see Section 23.1.4 )."},{"description":"Do not enable data checksums.","names":["--no-data-checksums"],"signature":"--no-data-checksums","source_url":"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS","summary":"Do not enable data checksums."},{"description":"Makes initdb read the bootstrap superuser's password from a file. The first line of the file is taken as the password.","names":["--pwfile= filename"],"signature":"--pwfile= filename","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWFILE","summary":"Makes initdb read the bootstrap superuser's password from a file. The first line of the file is taken as the password."},{"description":"Sets the default text search configuration. See default_text_search_config for further information.","names":["-T config","--text-search-config= config"],"signature":"-T config --text-search-config= config","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-TEXT-SEARCH-CONFIG","summary":"Sets the default text search configuration. See default_text_search_config for further information."},{"description":"Sets the user name of the bootstrap superuser . This defaults to the name of the operating-system user running initdb .","names":["-U username","--username= username"],"signature":"-U username --username= username","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-USERNAME","summary":"Sets the user name of the bootstrap superuser . This defaults to the name of the operating-system user running initdb ."},{"description":"Makes initdb prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.","names":["-W","--pwprompt"],"signature":"-W --pwprompt","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWPROMPT","summary":"Makes initdb prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up."},{"description":"This option specifies the directory where the write-ahead log should be stored.","names":["-X directory","--waldir= directory"],"signature":"-X directory --waldir= directory","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WALDIR","summary":"This option specifies the directory where the write-ahead log should be stored."},{"description":"Set the 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. 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.","names":["--wal-segsize= size"],"signature":"--wal-segsize= size","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WAL-SEGSIZE","summary":"Set the 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."},{"description":"Forcibly set the server parameter name to value during initdb , and also install that setting in the generated postgresql.conf 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.","names":["-c name = value","--set name = value"],"signature":"-c name = value --set name = value","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SET","summary":"Forcibly set the server parameter name to value during initdb , and also install that setting in the generated postgresql.conf 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."},{"description":"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 initdb uses to create the catalog tables. This option generates a tremendous amount of extremely boring output.","names":["-d","--debug"],"signature":"-d --debug","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DEBUG","summary":"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 initdb uses to create the catalog tables. This option generates a tremendous amount of extremely boring output."},{"description":"Run the bootstrap backend with the debug_discard_caches=1 option. This takes a very long time and is only of use for deep debugging.","names":["--discard-caches"],"signature":"--discard-caches","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DISCARD-CACHES","summary":"Run the bootstrap backend with the debug_discard_caches=1 option. This takes a very long time and is only of use for deep debugging."},{"description":"Specifies where initdb 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.","names":["-L directory"],"signature":"-L directory","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-L","summary":"Specifies where initdb 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."},{"description":"By default, when initdb 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.","names":["-n","--no-clean"],"signature":"-n --no-clean","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-CLEAN","summary":"By default, when initdb 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."},{"description":"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 option is useful for testing, but should not be used when creating a production installation.","names":["-N","--no-sync"],"signature":"-N --no-sync","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC","summary":"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 option is useful for testing, but should not be used when creating a production installation."},{"description":"By default, initdb safely writes all database files to disk. This option instructs initdb to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the base subdirectory and any other tablespace directories. Other files, such as those in pg_wal and pg_xact , will still be synchronized unless the --no-sync option is also specified. Note that if --no-sync-data-files is used in conjunction with --sync-method=syncfs , some or all of the aforementioned files and directories will be synchronized because syncfs processes entire file systems. This option is primarily intended for internal use by tools that separately ensure the skipped files are synchronized to disk.","names":["--no-sync-data-files"],"signature":"--no-sync-data-files","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC-DATA-FILES","summary":"By default, initdb safely writes all database files to disk. This option instructs initdb to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the base subdirectory and any other tablespace directories. Other files, such as those in pg_wal and pg_xact , will still be synchronized unless the --no-sync option is also specified."},{"description":"By default, initdb 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 initdb in platform-specific behavior, where those instructions are likely to be incorrect.","names":["--no-instructions"],"signature":"--no-instructions","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-INSTRUCTIONS","summary":"By default, initdb 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 initdb in platform-specific behavior, where those instructions are likely to be incorrect."},{"description":"Show internal settings and exit, without doing anything else. This can be used to debug the initdb installation.","names":["-s","--show"],"signature":"-s --show","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SHOW","summary":"Show internal settings and exit, without doing anything else. This can be used to debug the initdb installation."},{"description":"When set to fsync , which is the default, initdb 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. On Linux, syncfs 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 recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used.","names":["--sync-method= method"],"signature":"--sync-method= method","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-METHOD","summary":"When set to fsync , which is the default, initdb 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."},{"description":"Safely write all database files to disk and exit. This does not perform any of the normal initdb operations. Generally, this option is useful for ensuring reliable recovery after changing fsync from off to on .","names":["-S","--sync-only"],"signature":"-S --sync-only","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-ONLY","summary":"Safely write all database files to disk and exit. This does not perform any of the normal initdb operations. Generally, this option is useful for ensuring reliable recovery after changing fsync from off to on ."},{"description":"Print the initdb version and exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-VERSION","summary":"Print the initdb version and exit."},{"description":"Show help about initdb command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-HELP","summary":"Show help about initdb command line arguments, and exit."}],"related":[],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"sections_zh":[],"signature":"initdb [ option ...] [ --pgdata | -D ] directory","sources":[{"anchor":"","file":"app-initdb.html","label":"18.6 English manual · app-initdb.html","sha256":"ca8245d2c61740de3b11df2b81993b18e311705e2c23bebfa7cafda1bcd15321","url":"/docs/18/app-initdb.html"},{"anchor":"","file":"reference-server.html","label":"Server applications inventory","sha256":"e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3","url":"/docs/18/reference-server.html"}],"synopsis":["initdb [ option ...] [ --pgdata | -D ] directory"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-A authmethod --auth= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH"},"summary":"This option specifies the default authentication method for local users used in pg_hba.conf ( host and local lines). See Section 20.1 for an overview of valid values."},{"signature":{"text":"--auth-host= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-HOST"},"summary":"This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf ( host lines)."},{"signature":{"text":"--auth-local= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-LOCAL"},"summary":"This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf ( local lines)."},{"signature":{"text":"-D directory --pgdata= directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PGDATA"},"summary":"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 data directory later by the same variable."},{"signature":{"text":"-E encoding --encoding= encoding","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-ENCODING"},"summary":"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 PostgreSQL server are described in Section 23.3.1 ."},{"signature":{"text":"-g --allow-group-access","url":"/docs/18/app-initdb.html#APP-INITDB-ALLOW-GROUP-ACCESS"},"summary":"Allows users in the same group as the cluster owner to read all cluster files created by initdb . This option is ignored on Windows as it does not support POSIX -style group permissions."},{"signature":{"text":"--icu-locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-ICU-LOCALE"},"summary":"Specifies the ICU locale when the ICU provider is used. Locale support is described in Section 23.1 ."},{"signature":{"text":"--icu-rules= rules","url":"/docs/18/app-initdb.html#APP-INITDB-ICU-RULES"},"summary":"Specifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only."},{"signature":{"text":"-k --data-checksums","url":"/docs/18/app-initdb.html#APP-INITDB-DATA-CHECKSUMS"},"summary":"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 --no-data-checksums to disable checksums."},{"signature":{"text":"--locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE"},"summary":"Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in. Locale support is described in Section 23.1 ."},{"signature":{"text":"--lc-collate= locale --lc-ctype= locale --lc-messages= locale --lc-monetary= locale --lc-numeric= locale --lc-time= locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LC-COLLATE"},"summary":"Like --locale , but only sets the locale in the specified category."},{"signature":{"text":"--no-locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE"},"summary":"Equivalent to --locale=C ."},{"signature":{"text":"--builtin-locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-BUILTIN-LOCALE"},"summary":"Specifies the locale name when the builtin provider is used. Locale support is described in Section 23.1 ."},{"signature":{"text":"--locale-provider={ builtin | libc | icu }","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE-PROVIDER"},"summary":"This option sets the locale provider for databases created in the new cluster. It can be overridden in the CREATE DATABASE command when new databases are subsequently created. The default is libc (see Section 23.1.4 )."},{"signature":{"text":"--no-data-checksums","url":"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS"},"summary":"Do not enable data checksums."},{"signature":{"text":"--pwfile= filename","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWFILE"},"summary":"Makes initdb read the bootstrap superuser's password from a file. The first line of the file is taken as the password."},{"signature":{"text":"-T config --text-search-config= config","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-TEXT-SEARCH-CONFIG"},"summary":"Sets the default text search configuration. See default_text_search_config for further information."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-USERNAME"},"summary":"Sets the user name of the bootstrap superuser . This defaults to the name of the operating-system user running initdb ."},{"signature":{"text":"-W --pwprompt","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWPROMPT"},"summary":"Makes initdb prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up."},{"signature":{"text":"-X directory --waldir= directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WALDIR"},"summary":"This option specifies the directory where the write-ahead log should be stored."},{"signature":{"text":"--wal-segsize= size","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WAL-SEGSIZE"},"summary":"Set the 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."},{"signature":{"text":"-c name = value --set name = value","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SET"},"summary":"Forcibly set the server parameter name to value during initdb , and also install that setting in the generated postgresql.conf 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."},{"signature":{"text":"-d --debug","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DEBUG"},"summary":"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 initdb uses to create the catalog tables. This option generates a tremendous amount of extremely boring output."},{"signature":{"text":"--discard-caches","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DISCARD-CACHES"},"summary":"Run the bootstrap backend with the debug_discard_caches=1 option. This takes a very long time and is only of use for deep debugging."},{"signature":{"text":"-L directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-L"},"summary":"Specifies where initdb 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."},{"signature":{"text":"-n --no-clean","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-CLEAN"},"summary":"By default, when initdb 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."},{"signature":{"text":"-N --no-sync","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC"},"summary":"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 option is useful for testing, but should not be used when creating a production installation."},{"signature":{"text":"--no-sync-data-files","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC-DATA-FILES"},"summary":"By default, initdb safely writes all database files to disk. This option instructs initdb to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the base subdirectory and any other tablespace directories. Other files, such as those in pg_wal and pg_xact , will still be synchronized unless the --no-sync option is also specified."},{"signature":{"text":"--no-instructions","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-INSTRUCTIONS"},"summary":"By default, initdb 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 initdb in platform-specific behavior, where those instructions are likely to be incorrect."},{"signature":{"text":"-s --show","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SHOW"},"summary":"Show internal settings and exit, without doing anything else. This can be used to debug the initdb installation."},{"signature":{"text":"--sync-method= method","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-METHOD"},"summary":"When set to fsync , which is the default, initdb 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."},{"signature":{"text":"-S --sync-only","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-ONLY"},"summary":"Safely write all database files to disk and exit. This does not perform any of the normal initdb operations. Generally, this option is useful for ensuring reliable recovery after changing fsync from off to on ."},{"signature":{"text":"-V --version","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-VERSION"},"summary":"Print the initdb version and exit."},{"signature":{"text":"-? --help","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-HELP"},"summary":"Show help about initdb command line arguments, and exit."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Specifies the directory where the database cluster is to be stored; can be overridden using the -D option.","name":"PGDATA"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Specifies the default time zone of the created database cluster. The value should be a full time zone name (see Section 8.5.3 ).","name":"TZ"}],"title":"Environment variables"}],"tables_zh":[{"columns":[{"key":"signature","label":"选项与参数"},{"key":"summary","label":"说明"}],"key":"options","rows":[{"signature":{"text":"-A authmethod --auth= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH"},"summary":"该选项指定 pg_hba.conf 中本地用户默认使用的认证方法（ host 和 local 行）。有效值概览见 第 20.1 节 。"},{"signature":{"text":"--auth-host= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-HOST"},"summary":"该选项指定 pg_hba.conf 中本地用户通过 TCP/IP 连接时（ host 行）使用的认证方法。"},{"signature":{"text":"--auth-local= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-LOCAL"},"summary":"该选项指定 pg_hba.conf 中本地用户通过 Unix 域套接字连接时（ local 行）使用的认证方法。"},{"signature":{"text":"-D directory --pgdata= directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PGDATA"},"summary":"该选项指定数据库集簇应存放的目录。这是 initdb 所需的唯一信息，但也可以通过设置 PGDATA 环境变量来省去显式写出它；这通常更方便，因为数据库服务器（ postgres ）之后也可以通过同一变量找到数据目录。"},{"signature":{"text":"-E encoding --encoding= encoding","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-ENCODING"},"summary":"选择模板数据库的编码。这也将成为以后创建的任何数据库的默认编码，除非在创建时覆盖它。 PostgreSQL 服务器支持的字符集见 第 23.3.1 节 。"},{"signature":{"text":"-g --allow-group-access","url":"/docs/18/app-initdb.html#APP-INITDB-ALLOW-GROUP-ACCESS"},"summary":"允许与集簇拥有者同组的用户读取由 initdb 创建的所有集簇文件。该选项在 Windows 上会被忽略，因为它不支持 POSIX 风格的组权限。"},{"signature":{"text":"--icu-locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-ICU-LOCALE"},"summary":"当使用 ICU 提供程序时，指定 ICU 区域设置。区域设置支持见 第 23.1 节 。"},{"signature":{"text":"--icu-rules= rules","url":"/docs/18/app-initdb.html#APP-INITDB-ICU-RULES"},"summary":"指定附加的排序规则，以定制默认排序规则的行为。该选项仅支持 ICU。"},{"signature":{"text":"-k --data-checksums","url":"/docs/18/app-initdb.html#APP-INITDB-DATA-CHECKSUMS"},"summary":"对数据页启用校验和，以帮助检测原本会悄无声息发生的、由 I/O 系统导致的损坏。该项默认启用；使用 --no-data-checksums 可禁用校验和。"},{"signature":{"text":"--locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE"},"summary":"设置数据库集簇的默认区域设置。如果未指定该选项，区域设置将继承自 initdb 运行时所在的环境。区域设置支持见 第 23.1 节 。"},{"signature":{"text":"--lc-collate= locale --lc-ctype= locale --lc-messages= locale --lc-monetary= locale --lc-numeric= locale --lc-time= locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LC-COLLATE"},"summary":"类似于 --locale ，但只在指定的类别中设置区域设置。"},{"signature":{"text":"--no-locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE"},"summary":"等价于 --locale=C 。"},{"signature":{"text":"--builtin-locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-BUILTIN-LOCALE"},"summary":"当使用 builtin 提供程序时，指定区域设置名称。区域设置支持见 第 23.1 节 。"},{"signature":{"text":"--locale-provider={ builtin | libc | icu }","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE-PROVIDER"},"summary":"该选项设置新集簇中创建的数据库所使用的区域设置提供程序。后续创建新数据库时，可以在 CREATE DATABASE 命令中覆盖它。默认值为 libc （见 第 23.1.4 节 ）。"},{"signature":{"text":"--no-data-checksums","url":"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS"},"summary":"不启用数据校验和。"},{"signature":{"text":"--pwfile= filename","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWFILE"},"summary":"使 initdb 从文件中读取引导超级用户的密码。文件的第一行会被当作密码。"},{"signature":{"text":"-T config --text-search-config= config","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-TEXT-SEARCH-CONFIG"},"summary":"设置默认文本检索配置。更多信息见 default_text_search_config 。"},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-USERNAME"},"summary":"设置 引导超级用户 的用户名。默认值是运行 initdb 的操作系统用户名。"},{"signature":{"text":"-W --pwprompt","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWPROMPT"},"summary":"使 initdb 提示输入要赋给引导超级用户的密码。如果不打算使用密码认证，这一点并不重要。否则，在设置密码之前将无法使用密码认证。"},{"signature":{"text":"-X directory --waldir= directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WALDIR"},"summary":"该选项指定预写式日志（WAL）应存放的目录。"},{"signature":{"text":"--wal-segsize= size","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WAL-SEGSIZE"},"summary":"设置 WAL 段大小，单位为兆字节。这是 WAL 日志中每个独立文件的大小。默认大小为 16 兆字节。取值必须是 1 到 1024（兆字节）之间的 2 的幂。此选项只能在初始化时设置，之后无法更改。"},{"signature":{"text":"-c name = value --set name = value","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SET"},"summary":"在 initdb 期间强制将服务器参数 name 设为 value，并把该设置写入生成的 postgresql.conf 文件，使其在之后的服务器运行中也生效。此选项可多次使用，以设置多个参数。它主要用于环境条件导致服务器完全无法使用默认参数启动的情况。"},{"signature":{"text":"-d --debug","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DEBUG"},"summary":"打印引导后端的调试输出，以及少量普通用户通常不感兴趣的其他消息。引导后端是 initdb 用来创建系统目录表的程序。该选项会产生大量极其乏味的输出。"},{"signature":{"text":"--discard-caches","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DISCARD-CACHES"},"summary":"使用 debug_discard_caches=1 选项运行引导后端。这会花费很长时间，只对深度调试有用。"},{"signature":{"text":"-L directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-L"},"summary":"指定 initdb 初始化数据库集簇时应到哪里查找其输入文件。通常不需要这样做。若需要显式指定其位置，系统会提示。"},{"signature":{"text":"-n --no-clean","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-CLEAN"},"summary":"默认情况下，如果 initdb 发现某个错误使其无法完整创建数据库集簇，就会删除它在发现无法完成任务之前可能已创建的所有文件。该选项会禁止这种清理，因此对调试有用。"},{"signature":{"text":"-N --no-sync","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC"},"summary":"默认情况下， initdb 会等待所有文件都安全写入磁盘。该选项使 initdb 在不等待的情况下返回，速度更快，但这意味着如果后续操作系统崩溃，数据目录可能会损坏。通常，该选项适用于测试，但不应用于创建生产环境安装。"},{"signature":{"text":"--no-sync-data-files","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC-DATA-FILES"},"summary":"默认情况下， initdb 会将所有数据库文件安全地写入磁盘。该选项指示 initdb 跳过同步各个数据库目录中的所有文件、这些数据库目录本身以及表空间目录，也就是 base 子目录中的所有内容和任何其他表空间目录。其他文件，例如 pg_wal 和 pg_xact 中的文件，仍会被同步，除非也指定了 --no-sync 。"},{"signature":{"text":"--no-instructions","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-INSTRUCTIONS"},"summary":"默认情况下， initdb 会在其输出末尾写出如何启动集簇的说明。该选项会省略这些说明。它主要供那些对 initdb 进行平台特定封装的工具使用，因为在这种情况下那些说明很可能并不正确。"},{"signature":{"text":"-s --show","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SHOW"},"summary":"显示内部设置并退出，不执行其他操作。可用于调试 initdb 的安装。"},{"signature":{"text":"--sync-method= method","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-METHOD"},"summary":"设为 fsync （默认值）时， initdb 会递归打开并同步数据目录中的所有文件。查找文件时会跟随 WAL 目录和每个已配置表空间的符号链接。"},{"signature":{"text":"-S --sync-only","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-ONLY"},"summary":"将所有数据库文件安全地写入磁盘并退出。这不会执行任何常规的 initdb 操作。通常，该选项可用于在将 fsync 从 off 改为 on 后，确保能够可靠恢复。"},{"signature":{"text":"-V --version","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-VERSION"},"summary":"打印 initdb 版本并退出。"},{"signature":{"text":"-? --help","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-HELP"},"summary":"显示有关 initdb 命令行参数的帮助并退出。"}],"title":"手册中的选项"},{"columns":[{"key":"name","label":"变量"},{"key":"description","label":"含义"}],"key":"environment","rows":[{"description":"指定数据库集簇应存放的目录；可使用 -D 选项覆盖。","name":"PGDATA"},{"description":"指定诊断消息是否使用颜色。可选值为 always 、 auto 和 never 。","name":"PG_COLOR"},{"description":"指定所创建数据库集簇的默认时区。该值应为完整的时区名称（见 第 8.5.3 节 ）。","name":"TZ"}],"title":"环境变量"}],"zh_from":{"authored_translation":"source-derived-identity","body_sha256":"efbb9edf6f8ad88d1cd1bd990b65436fd739d209e6b06652b591c1a9df6d3241","kind":"same-version-chinese-manual-with-source-derived-identity","manual":{"anchor":"","build_id":107,"extraction":"command-description-and-options","fragment_sha256":"1b9deebca36756e5f767d927badee4051067299107b47af59a5c077da3aa7afb","locale":"zh-Hans","page_key":"app-initdb.html","source_hash":"e47f476aabee0456faa65306fa189efc8bed82fae38dacbd9965cf37d2b31cba","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/app-initdb.html","version":"18"},"runtime_rerun":false,"source_facts_revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}},"ManualEvidence":{"manual_path":"app-initdb.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-initdb.html","label":"18.6 English manual · app-initdb.html","sha256":"ca8245d2c61740de3b11df2b81993b18e311705e2c23bebfa7cafda1bcd15321","url":"/docs/18/app-initdb.html"},{"anchor":"","file":"reference-server.html","label":"Server applications inventory","sha256":"e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3","url":"/docs/18/reference-server.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"initdb","SourceDatabase":"center","Version":"18","Locale":"en","Title":"initdb","Summary":"initdb — create a new PostgreSQL database cluster","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-INITDB\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003einitdb — create a new \u003cspan\u003ePostgreSQL\u003c/span\u003e database cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.3.4.1\"\u003e\u003ccode\u003einitdb\u003c/code\u003e [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [ \u003ccode\u003e--pgdata\u003c/code\u003e | \u003ccode\u003e-D\u003c/code\u003e ] \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R1-APP-INITDB-1\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003ccode\u003einitdb\u003c/code\u003e creates a new \u003cspan\u003ePostgreSQL\u003c/span\u003e \u003ca href=\"/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\" rel=\"nofollow\"\u003e\u003c/a\u003e\u003ca href=\"/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\" title=\"Database cluster\" rel=\"nofollow\"\u003edatabase cluster\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eCreating a database cluster consists of creating the \u003ca href=\"/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\" rel=\"nofollow\"\u003e\u003c/a\u003e\u003ca href=\"/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\" title=\"Data directory\" rel=\"nofollow\"\u003edirectories\u003c/a\u003e 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 \u003ccode\u003epostgres\u003c/code\u003e, \u003ccode\u003etemplate1\u003c/code\u003e, and \u003ccode\u003etemplate0\u003c/code\u003e databases. The \u003ccode\u003epostgres\u003c/code\u003e database is a default database meant for use by users, utilities and third party applications. \u003ccode\u003etemplate1\u003c/code\u003e and \u003ccode\u003etemplate0\u003c/code\u003e are meant as source databases to be copied by later \u003ccode\u003eCREATE DATABASE\u003c/code\u003e commands. \u003ccode\u003etemplate0\u003c/code\u003e should never be modified, but you can add objects to \u003ccode\u003etemplate1\u003c/code\u003e, which by default will be copied into databases created later. See \u003ca href=\"/docs/18/manage-ag-templatedbs.html\" rel=\"nofollow\"\u003eSection 22.3\u003c/a\u003e for more details.\u003c/p\u003e\n\u003cp\u003eAlthough \u003ccode\u003einitdb\u003c/code\u003e 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 \u003ccode\u003echown\u003c/code\u003e to assign ownership of that directory to the database user account, then \u003ccode\u003esu\u003c/code\u003e to become the database user to run \u003ccode\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003einitdb\u003c/code\u003e 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 \u003ccode\u003einitdb\u003c/code\u003e creates. Since the server cannot be run as root, you must not run \u003ccode\u003einitdb\u003c/code\u003e as root either. (It will in fact refuse to do so.)\u003c/p\u003e\n\u003cp\u003eFor security reasons the new cluster created by \u003ccode\u003einitdb\u003c/code\u003e will only be accessible by the cluster owner by default. The \u003ccode\u003e--allow-group-access\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003einitdb\u003c/code\u003e initializes the database cluster\u0026#39;s default locale and character set encoding. These can also be set separately for each database when it is created. \u003ccode\u003einitdb\u003c/code\u003e determines those settings for the template databases, which will serve as the default for all other databases.\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode\u003einitdb\u003c/code\u003e uses the locale provider \u003ccode\u003elibc\u003c/code\u003e (see \u003ca href=\"/docs/18/locale.html#LOCALE-PROVIDERS\" rel=\"nofollow\"\u003eSection 23.1.4\u003c/a\u003e). The \u003ccode\u003elibc\u003c/code\u003e locale provider takes the locale settings from the environment, and determines the encoding from the locale settings.\u003c/p\u003e\n\u003cp\u003eTo choose a different locale for the cluster, use the option \u003ccode\u003e--locale\u003c/code\u003e. There are also individual options \u003ccode\u003e--lc-*\u003c/code\u003e and \u003ccode\u003e--icu-locale\u003c/code\u003e (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.\u003c/p\u003e\n\u003cp\u003eAlternatively, \u003ccode\u003einitdb\u003c/code\u003e can use the ICU library to provide locale services by specifying \u003ccode\u003e--locale-provider=icu\u003c/code\u003e. The server must be built with ICU support. To choose the specific ICU locale ID to apply, use the option \u003ccode\u003e--icu-locale\u003c/code\u003e. Note that for implementation reasons and to support legacy code, \u003ccode\u003einitdb\u003c/code\u003e will still select and initialize libc locale settings when the ICU locale provider is used.\u003c/p\u003e\n\u003cp\u003eWhen \u003ccode\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eMore details about locale settings can be found in \u003ca href=\"/docs/18/locale.html\" rel=\"nofollow\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eTo alter the default encoding, use the \u003ccode\u003e--encoding\u003c/code\u003e. More details can be found in \u003ca href=\"/docs/18/multibyte.html\" rel=\"nofollow\"\u003eSection 23.3\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.3.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH\"\u003e\u003cspan\u003e\u003ccode\u003e-A \u003cem\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--auth=\u003cem\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the default authentication method for local users used in \u003ccode\u003epg_hba.conf\u003c/code\u003e (\u003ccode\u003ehost\u003c/code\u003e and \u003ccode\u003elocal\u003c/code\u003e lines). See \u003ca href=\"/docs/18/auth-pg-hba-conf.html\" rel=\"nofollow\"\u003eSection 20.1\u003c/a\u003e for an overview of valid values.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003einitdb\u003c/code\u003e will prepopulate \u003ccode\u003epg_hba.conf\u003c/code\u003e entries using the specified authentication method for non-replication as well as replication connections.\u003c/p\u003e\n\u003cp\u003eDo not use \u003ccode\u003etrust\u003c/code\u003e unless you trust all local users on your system. \u003ccode\u003etrust\u003c/code\u003e is the default for ease of installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH-HOST\"\u003e\u003cspan\u003e\u003ccode\u003e--auth-host=\u003cem\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the authentication method for local users via TCP/IP connections used in \u003ccode\u003epg_hba.conf\u003c/code\u003e (\u003ccode\u003ehost\u003c/code\u003e lines).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH-LOCAL\"\u003e\u003cspan\u003e\u003ccode\u003e--auth-local=\u003cem\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the authentication method for local users via Unix-domain socket connections used in \u003ccode\u003epg_hba.conf\u003c/code\u003e (\u003ccode\u003elocal\u003c/code\u003e lines).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PGDATA\"\u003e\u003cspan\u003e\u003ccode\u003e-D \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--pgdata=\u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the directory where the database cluster should be stored. This is the only information required by \u003ccode\u003einitdb\u003c/code\u003e, but you can avoid writing it by setting the \u003ccode\u003ePGDATA\u003c/code\u003e environment variable, which can be convenient since the database server (\u003ccode\u003epostgres\u003c/code\u003e) can find the data directory later by the same variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-ENCODING\"\u003e\u003cspan\u003e\u003ccode\u003e-E \u003cem\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--encoding=\u003cem\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSelects 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 \u003cspan\u003ePostgreSQL\u003c/span\u003e server are described in \u003ca href=\"/docs/18/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" rel=\"nofollow\"\u003eSection 23.3.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eBy default, the template database encoding is derived from the locale. If \u003ca href=\"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE\" rel=\"nofollow\"\u003e\u003ccode\u003e--no-locale\u003c/code\u003e\u003c/a\u003e is specified (or equivalently, if the locale is \u003ccode\u003eC\u003c/code\u003e or \u003ccode\u003ePOSIX\u003c/code\u003e), then the default is \u003ccode\u003eUTF8\u003c/code\u003e for the ICU provider and \u003ccode\u003eSQL_ASCII\u003c/code\u003e for the \u003ccode\u003elibc\u003c/code\u003e provider.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ALLOW-GROUP-ACCESS\"\u003e\u003cspan\u003e\u003ccode\u003e-g\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--allow-group-access\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAllows users in the same group as the cluster owner to read all cluster files created by \u003ccode\u003einitdb\u003c/code\u003e. This option is ignored on \u003cspan\u003eWindows\u003c/span\u003e as it does not support POSIX-style group permissions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ICU-LOCALE\"\u003e\u003cspan\u003e\u003ccode\u003e--icu-locale=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the ICU locale when the ICU provider is used. Locale support is described in \u003ca href=\"/docs/18/locale.html\" rel=\"nofollow\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ICU-RULES\"\u003e\u003cspan\u003e\u003ccode\u003e--icu-rules=\u003cem\u003e\u003ccode\u003erules\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-DATA-CHECKSUMS\"\u003e\u003cspan\u003e\u003ccode\u003e-k\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. This is enabled by default; use \u003ca href=\"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS\" rel=\"nofollow\"\u003e\u003ccode\u003e--no-data-checksums\u003c/code\u003e\u003c/a\u003e to disable checksums.\u003c/p\u003e\n\u003cp\u003eEnabling 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 \u003ca href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\" rel=\"nofollow\"\u003e\u003ccode\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e view. See \u003ca href=\"/docs/18/checksums.html\" rel=\"nofollow\"\u003eSection 28.2\u003c/a\u003e for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LOCALE\"\u003e\u003cspan\u003e\u003ccode\u003e--locale=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that \u003ccode\u003einitdb\u003c/code\u003e runs in. Locale support is described in \u003ca href=\"/docs/18/locale.html\" rel=\"nofollow\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003e--locale-provider\u003c/code\u003e is \u003ccode\u003ebuiltin\u003c/code\u003e, \u003ccode\u003e--locale\u003c/code\u003e or \u003ccode\u003e--builtin-locale\u003c/code\u003e must be specified and set to \u003ccode\u003eC\u003c/code\u003e, \u003ccode\u003eC.UTF-8\u003c/code\u003e or \u003ccode\u003ePG_UNICODE_FAST\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LC-COLLATE\"\u003e\u003cspan\u003e\u003ccode\u003e--lc-collate=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--lc-ctype=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--lc-messages=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--lc-monetary=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--lc-numeric=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--lc-time=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLike \u003ccode\u003e--locale\u003c/code\u003e, but only sets the locale in the specified category.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-LOCALE\"\u003e\u003cspan\u003e\u003ccode\u003e--no-locale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEquivalent to \u003ccode\u003e--locale=C\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-BUILTIN-LOCALE\"\u003e\u003cspan\u003e\u003ccode\u003e--builtin-locale=\u003cem\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the locale name when the builtin provider is used. Locale support is described in \u003ca href=\"/docs/18/locale.html\" rel=\"nofollow\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LOCALE-PROVIDER\"\u003e\u003cspan\u003e\u003ccode\u003e--locale-provider={\u003ccode\u003ebuiltin\u003c/code\u003e|\u003ccode\u003elibc\u003c/code\u003e|\u003ccode\u003eicu\u003c/code\u003e}\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option sets the locale provider for databases created in the new cluster. It can be overridden in the \u003ccode\u003eCREATE DATABASE\u003c/code\u003e command when new databases are subsequently created. The default is \u003ccode\u003elibc\u003c/code\u003e (see \u003ca href=\"/docs/18/locale.html#LOCALE-PROVIDERS\" rel=\"nofollow\"\u003eSection 23.1.4\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-NO-DATA-CHECKSUMS\"\u003e\u003cspan\u003e\u003ccode\u003e--no-data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not enable data checksums.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PWFILE\"\u003e\u003cspan\u003e\u003ccode\u003e--pwfile=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMakes \u003ccode\u003einitdb\u003c/code\u003e read the bootstrap superuser\u0026#39;s password from a file. The first line of the file is taken as the password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-TEXT-SEARCH-CONFIG\"\u003e\u003cspan\u003e\u003ccode\u003e-T \u003cem\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--text-search-config=\u003cem\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the default text search configuration. See \u003ca href=\"/docs/18/runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG\" rel=\"nofollow\"\u003edefault_text_search_config\u003c/a\u003e for further information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-USERNAME\"\u003e\u003cspan\u003e\u003ccode\u003e-U \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--username=\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the user name of the \u003ca href=\"/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\" rel=\"nofollow\"\u003e\u003c/a\u003e\u003ca href=\"/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\" title=\"Bootstrap superuser\" rel=\"nofollow\"\u003ebootstrap superuser\u003c/a\u003e. This defaults to the name of the operating-system user running \u003ccode\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PWPROMPT\"\u003e\u003cspan\u003e\u003ccode\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--pwprompt\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMakes \u003ccode\u003einitdb\u003c/code\u003e prompt for a password to give the bootstrap superuser. If you don\u0026#39;t plan on using password authentication, this is not important. Otherwise you won\u0026#39;t be able to use password authentication until you have a password set up.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-WALDIR\"\u003e\u003cspan\u003e\u003ccode\u003e-X \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--waldir=\u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the directory where the write-ahead log should be stored.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-WAL-SEGSIZE\"\u003e\u003cspan\u003e\u003ccode\u003e--wal-segsize=\u003cem\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the \u003cem\u003eWAL segment size\u003c/em\u003e, 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.\u003c/p\u003e\n\u003cp\u003eIt 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther, less commonly used, options are also available:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SET\"\u003e\u003cspan\u003e\u003ccode\u003e-c \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--set \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForcibly set the server parameter \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e during \u003ccode\u003einitdb\u003c/code\u003e, and also install that setting in the generated \u003ccode\u003epostgresql.conf\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-DEBUG\"\u003e\u003cspan\u003e\u003ccode\u003e-d\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint debugging output from the bootstrap backend and a few other messages of lesser interest for the general public. The bootstrap backend is the program \u003ccode\u003einitdb\u003c/code\u003e uses to create the catalog tables. This option generates a tremendous amount of extremely boring output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-DISCARD-CACHES\"\u003e\u003cspan\u003e\u003ccode\u003e--discard-caches\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun the bootstrap backend with the \u003ccode\u003edebug_discard_caches=1\u003c/code\u003e option. This takes a very long time and is only of use for deep debugging.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-L\"\u003e\u003cspan\u003e\u003ccode\u003e-L \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies where \u003ccode\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-CLEAN\"\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-clean\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, when \u003ccode\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-SYNC\"\u003e\u003cspan\u003e\u003ccode\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-sync\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode\u003einitdb\u003c/code\u003e will wait for all files to be written safely to disk. This option causes \u003ccode\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-SYNC-DATA-FILES\"\u003e\u003cspan\u003e\u003ccode\u003e--no-sync-data-files\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode\u003einitdb\u003c/code\u003e safely writes all database files to disk. This option instructs \u003ccode\u003einitdb\u003c/code\u003e to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the \u003ccode\u003ebase\u003c/code\u003e subdirectory and any other tablespace directories. Other files, such as those in \u003ccode\u003epg_wal\u003c/code\u003e and \u003ccode\u003epg_xact\u003c/code\u003e, will still be synchronized unless the \u003ccode\u003e--no-sync\u003c/code\u003e option is also specified.\u003c/p\u003e\n\u003cp\u003eNote that if \u003ccode\u003e--no-sync-data-files\u003c/code\u003e is used in conjunction with \u003ccode\u003e--sync-method=syncfs\u003c/code\u003e, some or all of the aforementioned files and directories will be synchronized because \u003ccode\u003esyncfs\u003c/code\u003e processes entire file systems.\u003c/p\u003e\n\u003cp\u003eThis option is primarily intended for internal use by tools that separately ensure the skipped files are synchronized to disk.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-INSTRUCTIONS\"\u003e\u003cspan\u003e\u003ccode\u003e--no-instructions\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode\u003einitdb\u003c/code\u003e 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 \u003ccode\u003einitdb\u003c/code\u003e in platform-specific behavior, where those instructions are likely to be incorrect.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SHOW\"\u003e\u003cspan\u003e\u003ccode\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--show\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow internal settings and exit, without doing anything else. This can be used to debug the \u003cspan\u003einitdb\u003c/span\u003e installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SYNC-METHOD\"\u003e\u003cspan\u003e\u003ccode\u003e--sync-method=\u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode\u003efsync\u003c/code\u003e, which is the default, \u003ccode\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eOn Linux, \u003ccode\u003esyncfs\u003c/code\u003e 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 \u003ca href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\"\u003erecovery_init_sync_method\u003c/a\u003e for information about the caveats to be aware of when using \u003ccode\u003esyncfs\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option has no effect when \u003ccode\u003e--no-sync\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SYNC-ONLY\"\u003e\u003cspan\u003e\u003ccode\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--sync-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSafely write all database files to disk and exit. This does not perform any of the normal \u003cspan\u003einitdb\u003c/span\u003e operations. Generally, this option is useful for ensuring reliable recovery after changing \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-FSYNC\" rel=\"nofollow\"\u003efsync\u003c/a\u003e from \u003ccode\u003eoff\u003c/code\u003e to \u003ccode\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-INITDB-OPTION-VERSION\"\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan\u003einitdb\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-HELP\"\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan\u003einitdb\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.3.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-PGDATA\"\u003e\u003cspan\u003e\u003ccode\u003ePGDATA\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the directory where the database cluster is to be stored; can be overridden using the \u003ccode\u003e-D\u003c/code\u003e option.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-PG-COLOR\"\u003e\u003cspan\u003e\u003ccode\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-TZ\"\u003e\u003cspan\u003e\u003ccode\u003eTZ\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the default time zone of the created database cluster. The value should be a full time zone name (see \u003ca href=\"/docs/18/datatype-datetime.html#DATATYPE-TIMEZONES\" rel=\"nofollow\"\u003eSection 8.5.3\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.3.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003e\u003ccode\u003einitdb\u003c/code\u003e can also be invoked via \u003ccode\u003epg_ctl initdb\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.3.9\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/docs/18/app-pg-ctl.html\" title=\"pg_ctl\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_ctl\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/app-postgres.html\" title=\"postgres\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/auth-pg-hba-conf.html\" rel=\"nofollow\"\u003eSection 20.1\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"bbe220131ab5b791c647c6eed5b7fe347fed394563706e959c4c7b60a4491b2f","Payload":{"description":["initdb — create a new PostgreSQL database cluster"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-INITDB\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003einitdb — create a new \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.3.4.1\"\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [ \u003ccode class=\"option\"\u003e--pgdata\u003c/code\u003e | \u003ccode class=\"option\"\u003e-D\u003c/code\u003e ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-INITDB-1\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e creates a new \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e \u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\"\u003e\u003c/a\u003e\u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DB-CLUSTER\" title=\"Database cluster\"\u003edatabase cluster\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eCreating a database cluster consists of creating the \u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\"\u003e\u003c/a\u003e\u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-DATA-DIRECTORY\" title=\"Data directory\"\u003edirectories\u003c/a\u003e 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 \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e, \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e databases. The \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e database is a default database meant for use by users, utilities and third party applications. \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e and \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e are meant as source databases to be copied by later \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e commands. \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e should never be modified, but you can add objects to \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, which by default will be copied into databases created later. See \u003ca class=\"xref\" href=\"/docs/18/manage-ag-templatedbs.html\" title=\"22.3. Template Databases\"\u003eSection 22.3\u003c/a\u003e for more details.\u003c/p\u003e\n\u003cp\u003eAlthough \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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 \u003ccode class=\"command\"\u003echown\u003c/code\u003e to assign ownership of that directory to the database user account, then \u003ccode class=\"command\"\u003esu\u003c/code\u003e to become the database user to run \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e creates. Since the server cannot be run as root, you must not run \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e as root either. (It will in fact refuse to do so.)\u003c/p\u003e\n\u003cp\u003eFor security reasons the new cluster created by \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will only be accessible by the cluster owner by default. The \u003ccode class=\"option\"\u003e--allow-group-access\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e initializes the database cluster's default locale and character set encoding. These can also be set separately for each database when it is created. \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e determines those settings for the template databases, which will serve as the default for all other databases.\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e uses the locale provider \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e (see \u003ca class=\"xref\" href=\"/docs/18/locale.html#LOCALE-PROVIDERS\" title=\"23.1.4. Locale Providers\"\u003eSection 23.1.4\u003c/a\u003e). The \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e locale provider takes the locale settings from the environment, and determines the encoding from the locale settings.\u003c/p\u003e\n\u003cp\u003eTo choose a different locale for the cluster, use the option \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e. There are also individual options \u003ccode class=\"option\"\u003e--lc-*\u003c/code\u003e and \u003ccode class=\"option\"\u003e--icu-locale\u003c/code\u003e (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.\u003c/p\u003e\n\u003cp\u003eAlternatively, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e can use the ICU library to provide locale services by specifying \u003ccode class=\"literal\"\u003e--locale-provider=icu\u003c/code\u003e. The server must be built with ICU support. To choose the specific ICU locale ID to apply, use the option \u003ccode class=\"option\"\u003e--icu-locale\u003c/code\u003e. Note that for implementation reasons and to support legacy code, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will still select and initialize libc locale settings when the ICU locale provider is used.\u003c/p\u003e\n\u003cp\u003eWhen \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eMore details about locale settings can be found in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eTo alter the default encoding, use the \u003ccode class=\"option\"\u003e--encoding\u003c/code\u003e. More details can be found in \u003ca class=\"xref\" href=\"/docs/18/multibyte.html\" title=\"23.3. Character Set Support\"\u003eSection 23.3\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-A \u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the default authentication method for local users used in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e (\u003ccode class=\"literal\"\u003ehost\u003c/code\u003e and \u003ccode class=\"literal\"\u003elocal\u003c/code\u003e lines). See \u003ca class=\"xref\" href=\"/docs/18/auth-pg-hba-conf.html\" title=\"20.1. The pg_hba.conf File\"\u003eSection 20.1\u003c/a\u003e for an overview of valid values.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will prepopulate \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e entries using the specified authentication method for non-replication as well as replication connections.\u003c/p\u003e\n\u003cp\u003eDo not use \u003ccode class=\"literal\"\u003etrust\u003c/code\u003e unless you trust all local users on your system. \u003ccode class=\"literal\"\u003etrust\u003c/code\u003e is the default for ease of installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth-host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the authentication method for local users via TCP/IP connections used in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e (\u003ccode class=\"literal\"\u003ehost\u003c/code\u003e lines).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-AUTH-LOCAL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--auth-local=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eauthmethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the authentication method for local users via Unix-domain socket connections used in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e (\u003ccode class=\"literal\"\u003elocal\u003c/code\u003e lines).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PGDATA\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the directory where the database cluster should be stored. This is the only information required by \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e, but you can avoid writing it by setting the \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e environment variable, which can be convenient since the database server (\u003ccode class=\"command\"\u003epostgres\u003c/code\u003e) can find the data directory later by the same variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-ENCODING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E \u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--encoding=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSelects 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 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server are described in \u003ca class=\"xref\" href=\"/docs/18/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1. Supported Character Sets\"\u003eSection 23.3.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eBy default, the template database encoding is derived from the locale. If \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE\"\u003e\u003ccode class=\"option\"\u003e--no-locale\u003c/code\u003e\u003c/a\u003e is specified (or equivalently, if the locale is \u003ccode class=\"literal\"\u003eC\u003c/code\u003e or \u003ccode class=\"literal\"\u003ePOSIX\u003c/code\u003e), then the default is \u003ccode class=\"literal\"\u003eUTF8\u003c/code\u003e for the ICU provider and \u003ccode class=\"literal\"\u003eSQL_ASCII\u003c/code\u003e for the \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e provider.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ALLOW-GROUP-ACCESS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-g\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--allow-group-access\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAllows users in the same group as the cluster owner to read all cluster files created by \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e. This option is ignored on \u003cspan class=\"productname\"\u003eWindows\u003c/span\u003e as it does not support POSIX-style group permissions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ICU-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--icu-locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the ICU locale when the ICU provider is used. Locale support is described in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ICU-RULES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--icu-rules=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erules\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-DATA-CHECKSUMS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-k\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. This is enabled by default; use \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS\"\u003e\u003ccode class=\"option\"\u003e--no-data-checksums\u003c/code\u003e\u003c/a\u003e to disable checksums.\u003c/p\u003e\n\u003cp\u003eEnabling 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 \u003ca class=\"link\" href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\" title=\"27.2.17. pg_stat_database\"\u003e\u003ccode class=\"structname\"\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e view. See \u003ca class=\"xref\" href=\"/docs/18/checksums.html\" title=\"28.2. Data Checksums\"\u003eSection 28.2\u003c/a\u003e for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e runs in. Locale support is described in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"option\"\u003e--locale-provider\u003c/code\u003e is \u003ccode class=\"literal\"\u003ebuiltin\u003c/code\u003e, \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e or \u003ccode class=\"option\"\u003e--builtin-locale\u003c/code\u003e must be specified and set to \u003ccode class=\"literal\"\u003eC\u003c/code\u003e, \u003ccode class=\"literal\"\u003eC.UTF-8\u003c/code\u003e or \u003ccode class=\"literal\"\u003ePG_UNICODE_FAST\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LC-COLLATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-collate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-ctype=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-messages=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-monetary=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-numeric=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--lc-time=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLike \u003ccode class=\"option\"\u003e--locale\u003c/code\u003e, but only sets the locale in the specified category.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-locale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEquivalent to \u003ccode class=\"option\"\u003e--locale=C\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-BUILTIN-LOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--builtin-locale=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elocale\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the locale name when the builtin provider is used. Locale support is described in \u003ca class=\"xref\" href=\"/docs/18/locale.html\" title=\"23.1. Locale Support\"\u003eSection 23.1\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-LOCALE-PROVIDER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--locale-provider={\u003ccode class=\"literal\"\u003ebuiltin\u003c/code\u003e|\u003ccode class=\"literal\"\u003elibc\u003c/code\u003e|\u003ccode class=\"literal\"\u003eicu\u003c/code\u003e}\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option sets the locale provider for databases created in the new cluster. It can be overridden in the \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e command when new databases are subsequently created. The default is \u003ccode class=\"literal\"\u003elibc\u003c/code\u003e (see \u003ca class=\"xref\" href=\"/docs/18/locale.html#LOCALE-PROVIDERS\" title=\"23.1.4. Locale Providers\"\u003eSection 23.1.4\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-NO-DATA-CHECKSUMS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-checksums\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not enable data checksums.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PWFILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pwfile=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMakes \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e read the bootstrap superuser's password from a file. The first line of the file is taken as the password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-TEXT-SEARCH-CONFIG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--text-search-config=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econfig\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the default text search configuration. See \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-DEFAULT-TEXT-SEARCH-CONFIG\"\u003edefault_text_search_config\u003c/a\u003e for further information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-USERNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the user name of the \u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\"\u003e\u003c/a\u003e\u003ca class=\"glossterm\" href=\"/docs/18/glossary.html#GLOSSARY-BOOTSTRAP-SUPERUSER\" title=\"Bootstrap superuser\"\u003ebootstrap superuser\u003c/a\u003e. This defaults to the name of the operating-system user running \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-PWPROMPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pwprompt\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMakes \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-WALDIR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--waldir=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option specifies the directory where the write-ahead log should be stored.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-WAL-SEGSIZE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-segsize=\u003cem class=\"replaceable\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the \u003cem class=\"firstterm\"\u003eWAL segment size\u003c/em\u003e, 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.\u003c/p\u003e\n\u003cp\u003eIt 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther, less commonly used, options are also available:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--set \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForcibly set the server parameter \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e during \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e, and also install that setting in the generated \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-DEBUG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint debugging output from the bootstrap backend and a few other messages of lesser interest for the general public. The bootstrap backend is the program \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e uses to create the catalog tables. This option generates a tremendous amount of extremely boring output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-DISCARD-CACHES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--discard-caches\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun the bootstrap backend with the \u003ccode class=\"literal\"\u003edebug_discard_caches=1\u003c/code\u003e option. This takes a very long time and is only of use for deep debugging.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-L\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies where \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-CLEAN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, when \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-SYNC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e will wait for all files to be written safely to disk. This option causes \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-SYNC-DATA-FILES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync-data-files\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e safely writes all database files to disk. This option instructs \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the \u003ccode class=\"filename\"\u003ebase\u003c/code\u003e subdirectory and any other tablespace directories. Other files, such as those in \u003ccode class=\"literal\"\u003epg_wal\u003c/code\u003e and \u003ccode class=\"literal\"\u003epg_xact\u003c/code\u003e, will still be synchronized unless the \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e option is also specified.\u003c/p\u003e\n\u003cp\u003eNote that if \u003ccode class=\"option\"\u003e--no-sync-data-files\u003c/code\u003e is used in conjunction with \u003ccode class=\"option\"\u003e--sync-method=syncfs\u003c/code\u003e, some or all of the aforementioned files and directories will be synchronized because \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e processes entire file systems.\u003c/p\u003e\n\u003cp\u003eThis option is primarily intended for internal use by tools that separately ensure the skipped files are synchronized to disk.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-NO-INSTRUCTIONS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-instructions\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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 \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e in platform-specific behavior, where those instructions are likely to be incorrect.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SHOW\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--show\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow internal settings and exit, without doing anything else. This can be used to debug the \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SYNC-METHOD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode class=\"literal\"\u003efsync\u003c/code\u003e, which is the default, \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eOn Linux, \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e 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 \u003ca class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\"\u003erecovery_init_sync_method\u003c/a\u003e for information about the caveats to be aware of when using \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option has no effect when \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-SYNC-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSafely write all database files to disk and exit. This does not perform any of the normal \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e operations. Generally, this option is useful for ensuring reliable recovery after changing \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-FSYNC\"\u003efsync\u003c/a\u003e from \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-OPTION-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-OPTION-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-PGDATA\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the directory where the database cluster is to be stored; can be overridden using the \u003ccode class=\"option\"\u003e-D\u003c/code\u003e option.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-PG-COLOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-INITDB-ENVIRONMENT-TZ\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eTZ\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the default time zone of the created database cluster. The value should be a full time zone name (see \u003ca class=\"xref\" href=\"/docs/18/datatype-datetime.html#DATATYPE-TIMEZONES\" title=\"8.5.3. Time Zones\"\u003eSection 8.5.3\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003einitdb\u003c/code\u003e can also be invoked via \u003ccode class=\"command\"\u003epg_ctl initdb\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.3.9\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pg-ctl.html\" title=\"pg_ctl\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/auth-pg-hba-conf.html\" title=\"20.1. The pg_hba.conf File\"\u003eSection 20.1\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-A authmethod --auth= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH"},"summary":"This option specifies the default authentication method for local users used in pg_hba.conf ( host and local lines). See Section 20.1 for an overview of valid values."},{"signature":{"text":"--auth-host= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-HOST"},"summary":"This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf ( host lines)."},{"signature":{"text":"--auth-local= authmethod","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-AUTH-LOCAL"},"summary":"This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf ( local lines)."},{"signature":{"text":"-D directory --pgdata= directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PGDATA"},"summary":"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 data directory later by the same variable."},{"signature":{"text":"-E encoding --encoding= encoding","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-ENCODING"},"summary":"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 PostgreSQL server are described in Section 23.3.1 ."},{"signature":{"text":"-g --allow-group-access","url":"/docs/18/app-initdb.html#APP-INITDB-ALLOW-GROUP-ACCESS"},"summary":"Allows users in the same group as the cluster owner to read all cluster files created by initdb . This option is ignored on Windows as it does not support POSIX -style group permissions."},{"signature":{"text":"--icu-locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-ICU-LOCALE"},"summary":"Specifies the ICU locale when the ICU provider is used. Locale support is described in Section 23.1 ."},{"signature":{"text":"--icu-rules= rules","url":"/docs/18/app-initdb.html#APP-INITDB-ICU-RULES"},"summary":"Specifies additional collation rules to customize the behavior of the default collation. This is supported for ICU only."},{"signature":{"text":"-k --data-checksums","url":"/docs/18/app-initdb.html#APP-INITDB-DATA-CHECKSUMS"},"summary":"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 --no-data-checksums to disable checksums."},{"signature":{"text":"--locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE"},"summary":"Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in. Locale support is described in Section 23.1 ."},{"signature":{"text":"--lc-collate= locale --lc-ctype= locale --lc-messages= locale --lc-monetary= locale --lc-numeric= locale --lc-time= locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LC-COLLATE"},"summary":"Like --locale , but only sets the locale in the specified category."},{"signature":{"text":"--no-locale","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-LOCALE"},"summary":"Equivalent to --locale=C ."},{"signature":{"text":"--builtin-locale= locale","url":"/docs/18/app-initdb.html#APP-INITDB-BUILTIN-LOCALE"},"summary":"Specifies the locale name when the builtin provider is used. Locale support is described in Section 23.1 ."},{"signature":{"text":"--locale-provider={ builtin | libc | icu }","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-LOCALE-PROVIDER"},"summary":"This option sets the locale provider for databases created in the new cluster. It can be overridden in the CREATE DATABASE command when new databases are subsequently created. The default is libc (see Section 23.1.4 )."},{"signature":{"text":"--no-data-checksums","url":"/docs/18/app-initdb.html#APP-INITDB-NO-DATA-CHECKSUMS"},"summary":"Do not enable data checksums."},{"signature":{"text":"--pwfile= filename","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWFILE"},"summary":"Makes initdb read the bootstrap superuser's password from a file. The first line of the file is taken as the password."},{"signature":{"text":"-T config --text-search-config= config","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-TEXT-SEARCH-CONFIG"},"summary":"Sets the default text search configuration. See default_text_search_config for further information."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-USERNAME"},"summary":"Sets the user name of the bootstrap superuser . This defaults to the name of the operating-system user running initdb ."},{"signature":{"text":"-W --pwprompt","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-PWPROMPT"},"summary":"Makes initdb prompt for a password to give the bootstrap superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up."},{"signature":{"text":"-X directory --waldir= directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WALDIR"},"summary":"This option specifies the directory where the write-ahead log should be stored."},{"signature":{"text":"--wal-segsize= size","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-WAL-SEGSIZE"},"summary":"Set the 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."},{"signature":{"text":"-c name = value --set name = value","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SET"},"summary":"Forcibly set the server parameter name to value during initdb , and also install that setting in the generated postgresql.conf 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."},{"signature":{"text":"-d --debug","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DEBUG"},"summary":"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 initdb uses to create the catalog tables. This option generates a tremendous amount of extremely boring output."},{"signature":{"text":"--discard-caches","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-DISCARD-CACHES"},"summary":"Run the bootstrap backend with the debug_discard_caches=1 option. This takes a very long time and is only of use for deep debugging."},{"signature":{"text":"-L directory","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-L"},"summary":"Specifies where initdb 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."},{"signature":{"text":"-n --no-clean","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-CLEAN"},"summary":"By default, when initdb 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."},{"signature":{"text":"-N --no-sync","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC"},"summary":"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 option is useful for testing, but should not be used when creating a production installation."},{"signature":{"text":"--no-sync-data-files","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-SYNC-DATA-FILES"},"summary":"By default, initdb safely writes all database files to disk. This option instructs initdb to skip synchronizing all files in the individual database directories, the database directories themselves, and the tablespace directories, i.e., everything in the base subdirectory and any other tablespace directories. Other files, such as those in pg_wal and pg_xact , will still be synchronized unless the --no-sync option is also specified."},{"signature":{"text":"--no-instructions","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-NO-INSTRUCTIONS"},"summary":"By default, initdb 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 initdb in platform-specific behavior, where those instructions are likely to be incorrect."},{"signature":{"text":"-s --show","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SHOW"},"summary":"Show internal settings and exit, without doing anything else. This can be used to debug the initdb installation."},{"signature":{"text":"--sync-method= method","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-METHOD"},"summary":"When set to fsync , which is the default, initdb 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."},{"signature":{"text":"-S --sync-only","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-SYNC-ONLY"},"summary":"Safely write all database files to disk and exit. This does not perform any of the normal initdb operations. Generally, this option is useful for ensuring reliable recovery after changing fsync from off to on ."},{"signature":{"text":"-V --version","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-VERSION"},"summary":"Print the initdb version and exit."},{"signature":{"text":"-? --help","url":"/docs/18/app-initdb.html#APP-INITDB-OPTION-HELP"},"summary":"Show help about initdb command line arguments, and exit."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Specifies the directory where the database cluster is to be stored; can be overridden using the -D option.","name":"PGDATA"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Specifies the default time zone of the created database cluster. The value should be a full time zone name (see Section 8.5.3 ).","name":"TZ"}],"title":"Environment variables"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
