= PostgreSQL InitDB = The '''`initdb(1)`''' utility is shipped with PostgreSQL as a core component. <> ---- == Installation == The `initdb(1)` utility is usually packaged with the other core services in `postgresql`. ---- == Usage == For most usecases, simply run: {{{ initdb }}} === Data Directory === The default data directory will be implicitly used. Depending on the distribution, this may be any of: * `/usr/local/pgsql/data` * `/var/lib/postgresql/[version]/data/` ([[Linux/Debian|Debian]] and derivatives) * `/var/lib/postgres/data` ([[Linux/Arch|Arch]] and derivatives) The data directory can be configured by... * setting the `PGDATA` environment variable. * passing a different directory to `initdb(1)` (such as `initdb --pgdata=/path/to/data/directory`). * changing the `data_directory` parameter in the configuraiton file. === Locale === `initdb(1)` sets the locale for the entire cluster. It is stored in the template databases, and will propogate to all other databases. By default, `initdb(1)` looks up the locale using `libc`, takes the locale settings from the environment, and determines the encoding from the locale settings. Upon completion, `initdb(1)` prints the chosen locale settings. The locale can be configured by... * passing a different locale to `initdb(1)` (such as `initdb --locale=en_US.utf8`). * passing individual locale component settings to `initdb(1)` with the `--lc-*` options. === Encoding === Much like with locales, `initdb(1)` sets the character set encoding for the entire cluster. This will propogate to all other databases. By default, `initdb(1)` sets the encoding based on the locale. The encoding can be configured by passing a different encoding to `initdb(1)` (as with `initdb --encoding=UTF8`). === Data Checksums === If the cluster is not written to a filesystem that features checksums, PostgreSQL offers a built-in checksums that can offer the same integrity guarantees. To enable this, add the `--data-checksums` option to `initdb(1)`. ---- CategoryRicottone