win10下搭建PostgreSQL

 win10下搭建PostgreSQL

参考:

https://blog.csdn.net/chineseboytom/article/details/78868199

3、设置环境变量(cmd):

setx PGHOME E:PostgreSQL10

setx PGHOST 192.168.100.157

setx PGLIB %PGHOME%lib

setx PGDATA %PGHOME%data

setx Path "%Path%;%PGHOME%in"

重新登录

4、初始化数据库

.initdb.exe -D E:PostgreSQL10data -E UTF-8 --locale=chs -U postgres -W

5、注册为系统服务(以管理员权限打开cmd)

pg_ctl register -N PostgreSQL -D E:PostgreSQL10data

6、修改配置以支持远程连接

6.1 notepad D:Program FilesPostgreSQL10datapostgresql.conf

 设置:listen_addresses = '*'

           ssl = off

           port = 5432

           superuser_reserved_connections = 3

6.2 notepad D:Program FilesPostgreSQL10datapg_hba.conf

 设置ipv4段

host    all             all             0.0.0.0/0            md5

7、启动服务

net start PostgreSQL

##E:/PostgreSQL/10/bin/pg_ctl -D "E:PostgreSQL10data" -l logfile start

总结:上面标红的地方请特别注意,如果这些网络相关的设置没有设置对,则连接不上数据库。

原文地址:https://www.cnblogs.com/double-kill/p/10169402.html