PostgreSQL | Terminal Command Collection | Initialize (initdb)
Show Help
$ initdb --help
initdb initializes a PostgreSQL database cluster.
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 directory for the new database cluster
-E, --encoding=ENCODING default encoding for new databases
--locale=LOCALE default locale setting for new databases
--lc-collate=, --lc-ctype=, --lc-messages=LOCALE
--lc-monetary=, --lc-numeric=, --lc-time=LOCALE
default locale setting for each category in new databases
(default values are taken from the environment)
--no-locale same as --locale=C
--pwfile=FILE read the new superuser password from a file
-T, --text-search-config=CFG
default text search configuration
-U, --username=NAME database superuser name
-W, --pwprompt prompt for the new superuser password
-X, --waldir=WALDIR location of the transaction log directory
Less commonly used options:
-d, --debug print debugging output
-k, --data-checksums use data page checksums
-L DIRECTORY directory containing input files
-n, --no-clean leave files in place if an error occurs
-N, --no-sync do not sync to disk after completing the work
-s, --show show internal settings
-S, --sync-only only sync the data directory
Other options:
-V, --version show version information, then exit
-?, --help show this help, then exit
If the data directory is not specified, the PGDATA environment variable is used.
Report bugs to <pgsql-bugs@postgresql.org>.
Command Example
$ initdb --encoding=UTF-8 --no-locale --pgdata=c:/db/database --pwfile=c:/db/pw.txt
The files belonging to this database system will be owned by user "devkuma".
This user must also own the server process.
The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory c:/db/database ... done
creating subdirectories ... done
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... windows
creating configuration files ... done
running bootstrap script ... done
performing post-bootstrap initialization ... done
syncing data to disk ... done
Warning: "trust" authentication was specified for local connections.
You can change this by editing pg_hba.conf or by using the -A option,
or the --auth-local and --auth-host options the next time you run initdb.
Success. You can now start the server with:
pg_ctl -D c:/db/database -l logfile start