设置 postgres 的 initdb 编码

Bea*_*ker 3 postgresql postgresql-initdb postgresql-9.6 pg-ctl

当我尝试使用 init[db] 调用 pg_ctl 时,无法识别设置编码的选项:

pg_ctl init -D=D:\testdata -E=UTF8 -U=postgres
pg_ctl: illegal option -- E
Run Code Online (Sandbox Code Playgroud)

这有改变吗?我使用最新的 PostgreSQL 9.6(zip 下载,x64)。当我不使用 -E 开关时,一切正常,但数据库集群使用错误的编码进行初始化。

小智 6

pg_ctl没有选择-E。如果你想运行initdbpg_ctl你需要initdb使用-o例如传递选项pg_ctl initdb -D ... -o "-E=UTF8"

但直接调用要容易得多initdb

initdb -D=D:\testdata -E=UTF8 -U=postgres
Run Code Online (Sandbox Code Playgroud)