首次设置 Postgres 时出现问题

Mel*_*emi 5 postgresql mac-os-x

我对 MySQL 和 MongoDB(都在服务器上运行良好)有一些(尽管有限)的经验,但在使用 Postgres 时遇到了问题,并且发现文档对于像我这样的新手来说缺乏。

Postgres 已安装并正在运行。但我无法从客户端连接。

pg_hba.conf 看起来像这样(我添加了最后一行):

# TYPE  DATABASE        USER            CIDR-ADDRESS            METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

## Added by me
host    all             all             10.0.1.201/32           trust
Run Code Online (Sandbox Code Playgroud)

现在,如果我去客户端10.0.1.201并尝试psql -h server.domain.com我得到一个错误:

psql: could not connect to server: Connection refused
    Is the server running on host "server.domain.com" (10.0.1.38) and accepting
    TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)

为此客户端 <-> 服务器连接设置了 ssh 授权密钥。也可以选择 Kerberos。似乎我在这里可能有太多选择?不太确定如何解决这个问题?我可以验证 Postgres 正在运行。

meltemi$ sudo lsof -i -P | grep -i ':5432'
meltemi$
Run Code Online (Sandbox Code Playgroud)

让我相信也许它没有在听?

想法?

Dan*_*ons 6

接下来要检查的可能是您的行中postgresql.conf看起来像这样:

listen_addresses = '*'
Run Code Online (Sandbox Code Playgroud)

更改该行后,您必须重新启动。否则你的 pg_hba.conf 看起来不错。

祝你好运!入门是一个很大的障碍,但是一旦你通过它,你可能会发现与 MySQL 相比,事情要简单得多,而且更加一致。