我正在我的新 macbook pro 上设置 postgresql/pgadmin。但是,当我注册一个新服务器时,出现错误:
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
我浏览了这个问题,显然答案是编辑 pg_hba.conf
文件。但是,我需要帮助:
1) 如何找到并打开该文件?
2) 打开它后,我需要添加哪些语句来解决问题?
有人可以帮忙吗?
提前致谢!
最佳答案
它位于 data
文件夹内。
Eg: PostgreSQL\9.4\data\pg_hba.conf
在那里你会找到以下地方。
# IPv4 local connections:
host all all 127.0.0.1/32 md5
如果您想从不同的 IP 访问,请添加更改 IP 的同一行的副本。 解释得很好here .
另外,我建议您检查放置在同一目录中的 postgresql.conf
是否有以下行的注释。
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
关于postgresql/pgAdmin - 服务器不监听问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37515400/