April 25, 2023

initdb PostgreSQL tool

Postgres initdb utility


initdb initializes/creates a new PostgreSQL database cluster.

initdb --help

Usage:
  initdb [OPTION]... [DATADIR]

Options:
  -A, --auth=METHOD          default authentication method for local connections
      --auth-host=METHOD    default authentication method for local TCP/IP connections
      --auth-local=METHOD    default authentication method for local-socket connections
  -D, --pgdata=]DATADIR      location for this database cluster, data directory (if not specified, PGDATA will be used)
  -E, --encoding=ENCODING    set default encoding for new databases
  -g, --allow-group-access  allow group read/execute on data directory
      --icu-locale=LOCALE    set ICU locale ID for new databases
  -k, --data-checksums      use data page checksums
      --locale=LOCALE        set default locale for new databases
      --lc-collate=, --lc-ctype=, --lc-messages=LOCALE
      --lc-monetary=, --lc-numeric=, --lc-time=LOCALE   set default locale in the respective category for new databases (default taken from environment)
      --no-locale            equivalent to --locale=C
      --locale-provider={libc|icu}   set default locale provider for new databases
      --pwfile=FILE          read password for the new superuser from file
  -T, --text-search-config=CFG default text search configuration
  -U, --username=NAME        database superuser name
  -W, --pwprompt              prompt for a password for the new superuser, to force super user to provide password
  -X, --waldir=WALDIR        location for the write-ahead log directory
      --wal-segsize=SIZE      size of WAL segments, in megabytes

Less commonly used options:
  -d, --debug                 generate lots of debugging output
      --discard-caches      set debug_discard_caches=1
  -L DIRECTORY             where to find the input files
  -n, --no-clean             do not clean up after errors
  -N, --no-sync              do not wait for changes to be written safely to disk
      --no-instructions     do not print instructions for next steps
  -s, --show                  show internal settings
  -S, --sync-only           only sync database files to disk, then exit

Other options:
  -V, --version             output version information, then exit
  -?, --help                show this help, then exit

initdb --version
initdb -D /usr/local/pgsql/data
initdb -D /data/postgres/9.5/5301 -U
initdb -D /data/postgres/14.6/5301 -W
initdb -D /usr/edbstore --wal-segsize 1024 -W
initdb -D /data/postgres/15.2/5301 --pwprompt --username=postgresadmin


Related PostgreSQL Articles: pg_upgrade utility in PostgreSQL

No comments:

Post a Comment