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:

The data directory can be configured by...

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...

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

PostgreSQL/InitDB (last edited 2023-04-02 18:12:00 by DominicRicottone)