Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
windows server上的postgresql无法连接_Windows_Postgresql - Fatal编程技术网

windows server上的postgresql无法连接

windows server上的postgresql无法连接,windows,postgresql,Windows,Postgresql,这是在PostgreSQL 9.6.2中实现的 起初我以为这是我对django或其他什么的问题,但结果很可能不是。服务器与客户端位于不同的计算机上,因此我需要连接到LAN地址。由于这不起作用,我在服务器上进行了测试: PS C:\WINDOWS\system32> Test-NetConnection 192.168.1.9 -p 5432 ComputerName : 192.168.1.9 RemoteAddress : 192.168.1.9 RemotePort

这是在PostgreSQL 9.6.2中实现的

起初我以为这是我对django或其他什么的问题,但结果很可能不是。服务器与客户端位于不同的计算机上,因此我需要连接到LAN地址。由于这不起作用,我在服务器上进行了测试:

PS C:\WINDOWS\system32> Test-NetConnection 192.168.1.9 -p 5432


ComputerName     : 192.168.1.9
RemoteAddress    : 192.168.1.9
RemotePort       : 5432
InterfaceAlias   : Ethernet
SourceAddress    : 192.168.1.9
TcpTestSucceeded : True
事实上,这就是我的博士后:

TCP    0.0.0.0:5432           Windows10:0            LISTENING
[postgres.exe]
然而,即使在“服务器”(我的台式机,而不是我的笔记本电脑上安装了应用程序),我也无法连接到远程端口:

但是
-h localhost
没有连接,我可以看到我的conf文件:

postgres=# show config_file;
                     config_file
------------------------------------------------------
 C:/Program Files/PostgreSQL/9.6/data/postgresql.conf
(1 row)


postgres=# show hba_file;
                     hba_file
--------------------------------------------------
 C:/Program Files/PostgreSQL/9.6/data/pg_hba.conf
(1 row)
这些文件在初始安装后不存在,但我编辑了示例并保存了一份副本,因此可以看到它们显示在那里。 我对主conf文件所做的唯一更改是以下四行:

listen_addresses = '*'      # what IP address(es) to listen on;
port = 5432             # (change requires restart)
superuser_reserved_connections = 3  # (change requires restart)
ssl = off               # (change requires restart)
样本中的所有其他内容都被注释掉了

我只在pg_hba的底部添加了一行:

host    all             dev             192.168.1.0/24         trust
这就把我带到了防火墙。我添加了一个允许连接到端口的规则,但现在我已经完全关闭了防火墙。我还在允许通过防火墙连接的应用列表中添加了PostgreSQL Server的公共和私有标志。正如你在上面看到的,它在倾听

可能是什么问题

编辑:

配置文件夹的内容:

PS C:\Program Files\PostgreSQL\9.6\share> dir


    Diretório: C:\Program Files\PostgreSQL\9.6\share


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----   Saturday, 11, 3, 2017                   contrib
                          8:16 PM
d-----   Saturday, 11, 3, 2017                   extension
                          8:19 PM
d-----   Saturday, 11, 3, 2017                   locale
                          8:16 PM
d-----   Saturday, 11, 3, 2017                   timezone
                          8:19 PM
d-----   Saturday, 11, 3, 2017                   timezonesets
                          8:19 PM
d-----   Saturday, 11, 3, 2017                   tsearch_data
                          8:18 PM
-a----  Wednesday, 22, 2, 2017             75988 conversion_create.sql
                          5:35 PM
-a----  Wednesday, 22, 2, 2017            109286 information_schema.sql
                          4:29 PM
-a----    Saturday, 11, 3, 2017             4481 pg_hba.conf
                         10:26 PM
-a----  Wednesday, 22, 2, 2017              4412 pg_hba.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017              1636 pg_ident.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017               604 pg_service.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017            650392 postgres.bki
                          5:26 PM
-a----  Wednesday, 22, 2, 2017            117036 postgres.description
                          5:26 PM
-a----  Wednesday, 22, 2, 2017                50 postgres.shdescription
                          5:26 PM
-a----      Sunday, 12, 3, 2017            22258 postgresql.conf
                         12:45 AM
-a----  Wednesday, 22, 2, 2017             22201 postgresql.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017               278 psqlrc.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017              5690 recovery.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017             25073 snowball_create.sql
                          5:35 PM
-a----  Wednesday, 22, 2, 2017             33114 sql_features.txt
                          4:29 PM
-a----  Wednesday, 22, 2, 2017             37157 system_views.sql
                          4:29 PM

“这些文件在初始安装后不存在”-这是不可能的。如果它们不存在,Postgres甚至不会启动(此外:将数据目录放入
c:\Program Files
)@a_horse_和\u no_名称,那么它们在那一点上并不存在,而且它确实适用于本地主机连接以及开发用户和数据库的初始创建。我已经将目录的完整列表添加到我的post.ooho!谢谢你澄清:)现在我明白了。共享下的文件不是要编辑的正确文件:)嘿,好的,现在它可以工作了。请随意发布答案:我需要的文件不是在
share
下,而是在
data
ps>下。您能更详细地介绍一下数据目录吗?它只是局域网上的一个开发服务器,这里没有外部暴露。
PS C:\Program Files\PostgreSQL\9.6\share> dir


    Diretório: C:\Program Files\PostgreSQL\9.6\share


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----   Saturday, 11, 3, 2017                   contrib
                          8:16 PM
d-----   Saturday, 11, 3, 2017                   extension
                          8:19 PM
d-----   Saturday, 11, 3, 2017                   locale
                          8:16 PM
d-----   Saturday, 11, 3, 2017                   timezone
                          8:19 PM
d-----   Saturday, 11, 3, 2017                   timezonesets
                          8:19 PM
d-----   Saturday, 11, 3, 2017                   tsearch_data
                          8:18 PM
-a----  Wednesday, 22, 2, 2017             75988 conversion_create.sql
                          5:35 PM
-a----  Wednesday, 22, 2, 2017            109286 information_schema.sql
                          4:29 PM
-a----    Saturday, 11, 3, 2017             4481 pg_hba.conf
                         10:26 PM
-a----  Wednesday, 22, 2, 2017              4412 pg_hba.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017              1636 pg_ident.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017               604 pg_service.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017            650392 postgres.bki
                          5:26 PM
-a----  Wednesday, 22, 2, 2017            117036 postgres.description
                          5:26 PM
-a----  Wednesday, 22, 2, 2017                50 postgres.shdescription
                          5:26 PM
-a----      Sunday, 12, 3, 2017            22258 postgresql.conf
                         12:45 AM
-a----  Wednesday, 22, 2, 2017             22201 postgresql.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017               278 psqlrc.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017              5690 recovery.conf.sample
                          4:29 PM
-a----  Wednesday, 22, 2, 2017             25073 snowball_create.sql
                          5:35 PM
-a----  Wednesday, 22, 2, 2017             33114 sql_features.txt
                          4:29 PM
-a----  Wednesday, 22, 2, 2017             37157 system_views.sql
                          4:29 PM