小编ift*_*itz的帖子

如果我指定主机 localhost,psql 会中断

我知道有人过这个或类似的问题 其他地方。其他答案都没有对我有用。

机器是 Macbook Pro 2014 / OS X Yosemite 10.10,通过 Homebrew 安装了 Postgres 9.3.5。

如果我没有指定主机,我只能连接到我的本地 postgres 实例。这有效:

psql -Umyuser -d mydb
sql (9.4.4)
Type "help" for help.

myuser=# 
Run Code Online (Sandbox Code Playgroud)

-h localhost 才不是:

psql -Umyuser -d mydb -h localhost
psql: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
Run Code Online (Sandbox Code Playgroud)

在我收到这条消息之前,它暂停了很长时间。

我正在尝试设置一个似乎想要指定 localhost 的第三方工具,因此不能仅将其关闭。

如果我理解我在其他地方正确阅读的内容,那么如果您使用 TCP/IP 并指定-h localhost强制使用,则 postgres 的行为会有所不同。因此,我在 中添加了以下内容pg_hba.conf

local   all …
Run Code Online (Sandbox Code Playgroud)

postgresql tcpip postgresql-9.3

5
推荐指数
1
解决办法
2891
查看次数

标签 统计

postgresql ×1

postgresql-9.3 ×1

tcpip ×1