1. 下载二进制压缩包
https://www.enterprisedb.com/download-postgresql-binaries
2. 解压后在压缩包的bin目录下执行初始化DB命令
initdb.exe -D .\data -U pguser -W -E UTF8 -A scram-sha-256 --locale=en_US
initdb
详细说明文档:https://www.postgresql.org/docs/current/app-initdb.html
3. 启动DB服务
pg_ctl.exe -D .\data -l logs start
4. 连接到DB服务
psql.exe -U pguser -h 127.0.0.1 -p 5432 -d postgres
结束DB服务
pg_ctl.exe -D .\data -m smart stop # or `-m immediate` without waiting for active connections to finish