应该能够在没有主机Postgres.app的情况下运行psql



Postgres.app文档逐字逐句地说:一旦正确设置了路径,就应该能够在没有主机的情况下运行psql。(如果没有,请通过执行哪个psql检查PATH中是否加载了正确的版本(对我来说不是这样。

这就是我的处境。没有Postgres应用程序(任何地方都没有大象(:

$ which psql
/Applications/Postgres.app/Contents/Versions/9.3/bin/psql

这是正确的,也是Heroku所说的要寻找的。Heroku还告诉我下面的命令应该有效,但它不起作用:

$ psql -h localhost
psql: 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" (fe80::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?

然而,当我双击postgres.app并打开它时,我可以让它工作。

$ psql
psql (9.3.3)
Type "help" for help.
johncurry=#

文档特别指出,它应该在没有localhost的情况下工作。我的设置正确吗?还是需要更改一些内容?上面的代码让我觉得一切都正常工作,但"应该在没有主机的情况下工作"的事情让我不确定。

您使用的是postgres.app中的psql。默认情况下,它被配置为从postgres.app连接到数据库服务器。如果postgres.app没有运行,这将不起作用。

如果我们没有-h,您必须运行postgres.app

如果你想运行后台PostgreSQL服务器,postgres.app不是你想要的。从Homebrew安装或使用EnterpriseDB安装程序包。

最新更新