win10下搭建PostgreSQL
參考:
https://blog.csdn.net/chineseboytom/article/details/78868199
3、設置環境變量(cmd):
setx PGHOME E:\PostgreSQL\10
setx PGHOST 192.168.100.157
setx PGLIB %PGHOME%\lib
setx PGDATA %PGHOME%\data
setx Path "%Path%;%PGHOME%\bin"
重新登錄
4、初始化數據庫
.\initdb.exe -D E:\PostgreSQL\10\data -E UTF-8 --locale=chs -U postgres -W
5、注冊為系統服務(以管理員權限打開cmd)
pg_ctl register -N PostgreSQL -D E:\PostgreSQL\10\data
6、修改配置以支持遠程連接
6.1 notepad D:\Program Files\PostgreSQL\10\data\postgresql.conf
設置:listen_addresses = '*'
ssl = off
port = 5432
superuser_reserved_connections = 3
6.2 notepad D:\Program Files\PostgreSQL\10\data\pg_hba.conf
設置ipv4段
host all all 0.0.0.0/0 md5
7、啟動服務
net start PostgreSQL
##E:/PostgreSQL/10/bin/pg_ctl -D "E:\PostgreSQL\10\data" -l logfile start
總結:上面標紅的地方請特別注意,如果這些網絡相關的設置沒有設置對,則連接不上數據庫。
