简体   繁体   English

使用postgreSQL在pgAdmin III中“服务器不听”

[英]“Server doesn't listen” in pgAdmin III with postgreSQL

First of all : I'm a novice in what touches to databases. 首先:我是触及数据库的新手。

I'm using postgreSQL with pgAdmin III, and it worked perfectly fine until some days ago : Some days ago, when I was not working on it, I saw in the "background process" of Windows that several identical postgreSQL programs (?) were running, and I decided to stop them, because I was not using them at the time. 我正在使用带有pgAdmin III的postgreSQL,它在几天前工作得很好:几天前,当我没有工作时,我在Windows的“后台进程”中看到几个相同的postgreSQL程序(?)是跑步,我决定阻止他们,因为我当时没有使用它们。 Mistake : Now, when I try to connect to the server (on localhost), I receive the error message : 错误:现在,当我尝试连接到服务器(在localhost上)时,收到错误消息:

"Server doesn't listen" “服务器不听”

The server doesn't accept connections: the connection library reports could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? 服务器不接受连接:连接库报告无法连接到服务器:连接被拒绝(0x0000274D / 10061)服务器是否在主机“localhost”(:: 1)上运行并接受端口5432上的TCP / IP连接? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? 无法连接到服务器:连接被拒绝(0x0000274D / 10061)服务器是否在主机“localhost”(127.0.0.1)上运行并接受端口5432上的TCP / IP连接?

I already took a look on similar topics on stackoverflow, looked the listen_address file, the postgresql.conf and pg_hba.conf files, but everything seems to be "normal" (according to what I read in these topics). 我已经看过stackoverflow上的类似主题,查看了listen_address文件,postgresql.conf和pg_hba.conf文件,但是一切似乎都是“正常的”(根据我在这些主题中读到的内容)。

I posted this because... well, I didn't find any other person that did what I did (stopping the background process, and then not being able to reconnect). 我发布这个是因为......好吧,我没有找到任何其他人做我做的事情(停止后台进程,然后无法重新连接)。

Use Services (Start → Run → services.msc) and look for the postgresql-[version] service. 使用服务(开始→运行→services.msc)并查找postgresql- [version]服务。 Is it running? 它在运行吗?

  • If not, try to start it. 如果没有,请尝试启动它。
    • If that works, you can make it startup automatically by changing the Startup Type with Windows to Automatic ; 如果可行,您可以通过将Windows的“启动类型”更改为“ AutomaticAutomatic启动; or perhaps Automatic, delayed start if you don't want it to slow down startup too much. 或者如果您不希望它太慢地降低启动速度Automatic, delayed start可能会Automatic, delayed start
  • If you can't start it, you may have just installed pgAdmin and not installed PostgreSQL itself. 如果你无法启动它,你可能刚刚安装了pgAdmin而没有安装PostgreSQL本身。
  • If it won't start open the Event Viewer (Start → Run → Eventvwr) and look for error messages relating to the PostgreSQL service. 如果它无法启动事件查看器(开始→运行→Eventvwr)并查找与PostgreSQL服务相关的错误消息。

Edit \\data\\postgresql.conf find and edit this line listen_addresses to 编辑\\data\\postgresql.conf找到并编辑此行listen_addresses

listen_addresses = '*'

and uncomment 并取消注释

port = 5432

For security reasons, PostgreSQL does not listen on all available IP addresses on the server machine initially. 出于安全原因, PostgreSQL最初不会侦听服务器计算机上的所有可用IP地址 In order to access the server over the network, you need to enable listening on the address first. 要通过网络访问服务器,您需要首先启用侦听地址。

For PostgreSQL servers starting with version 8.0 , this is controlled using the "listen_addresses" parameter in the postgresql.conf file . 对于从8.0版开始的PostgreSQL服务器,使用postgresql.conf文件中的“listen_addresses”参数进行控制。 Here, you can enter a list of IP addresses the server should listen on, or simply use ' '* to listen on all available IP addresses. 在这里,您可以输入服务器应该监听的IP地址列表,或者只使用 “*”来监听所有可用的IP地址。 For earlier servers (Version 7.3 or 7.4), you'll need to set the "tcpip_socket" parameter to 'true' . 对于早期的服务器 (版本7.3或7.4),您需要将“tcpip_socket”参数设置为“true”

You can use the postgresql.conf editor that is built into pgAdmin III to edit the postgresql.conf configuration file. 您可以使用pgAdmin III中内置的postgresql.conf编辑器来编辑postgresql.conf配置文件。 After changing this file, you need to restart the server process to make the setting effective. 更改此文件后,您需要重新启动服务器进程以使设置生效。

If you double-checked your configuration but still get this error message, it's still unlikely that you encounter a fatal PostgreSQL misbehaviour. 如果您仔细检查了配置但仍然收到此错误消息,那么您仍然不太可能遇到致命的PostgreSQL错误行为。 You probably have some low level network connectivity problems (eg firewall configuration). 您可能有一些低级网络连接问题(例如防火墙配置)。 Please check this thoroughly before reporting a bug to the PostgreSQL community. 在向PostgreSQL社区报告错误之前,请仔细检查。

Credits: PostgreSQL - Guru Hint. 致谢:PostgreSQL - Guru提示。

If on Windows, it could be a Firewall issue. 如果在Windows上,它可能是防火墙问题。 Try adding rules (TCP as protocol should work) for postgres using post 5432 (or whatever post you might use). 尝试使用post 5432(或您可能使用的任何帖子)为postgres添加规则(TCP作为协议应该工作)。

只需转到任务管理器 - >服务 - > postgresql-x64-9.4 - PostgreSQL Server 9.4(右键单击) - >启动服务从那里只需刷新postgresql并连接,一切都会好的。

I tried all the given methods. 我尝试了所有给定的方法。 The postgresql service was running fine. postgresql服务运行正常。 Finally, logged in as administrator in Windows. 最后,在Windows中以管理员身份登录。 It worked. 有效。 Guess, postgresql doesn't allow itself to be run in a non-admin user. 猜猜看,postgresql不允许自己在非管理员用户中运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM