Search code examples
postgresqlpostgresql-9.6postgresql-initdbpg-ctl

set initdb encoding for postgres


When I try to call pg_ctl with init[db] the option for setting the encoding is not recognized:

pg_ctl init -D=D:\testdata -E=UTF8 -U=postgres
pg_ctl: illegal option -- E

Has this changed? I used latest PostgreSQL 9.6 (zip download, x64). When I don't use the -E switch everything works but the database cluster is initialized with the wrong encoding.


Solution

  • pg_ctl does not have an option -E. If you want to run initdb through pg_ctl, you need to pass the initdb options using -o e.g. pg_ctl initdb -D ... -o "-E=UTF8"

    But it's a lot easier to call initdb directly:

    initdb -D=D:\testdata -E=UTF8 -U=postgres