安装Postgres.app但它不起作用

rod*_*ves 23 postgresql heroku psql

我刚刚在我的Mac上安装了Postgres.app但它无法正常工作.我完成了安装,应用程序图标在菜单栏上,它说它正在侦听端口5432,但是,如果我尝试从命令行运行它会发生什么:

~ $ psql
zsh: correct 'psql' to 'sl' [nyae]? n
zsh: command not found: psql
Run Code Online (Sandbox Code Playgroud)

我之前通过Homebrew安装了PostgreSQL,但在安装Postgres.app之前删除了它.我正在运行Mac OS X Lion.

我感谢任何帮助,我真的希望在我的机器上运行PostgreSQL.

mu *_*ort 47

psqlPostgres.app 的二进制文件位于应用程序包中,您必须将相应的目录添加到您的应用程序包中PATH.从精细手册:

配置你的 $PATH

Postgres.app包含许多命令行工具.如果要使用它们,则必须配置$PATH变量.

如果您使用的是bash(OS X上的默认shell),请将以下行添加到~/.bash_profile:

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
Run Code Online (Sandbox Code Playgroud)

[...]

因此,请PATH在zsh配置文件中调整您的设置以包含

Contents/Versions/latest/bin 
Run Code Online (Sandbox Code Playgroud)

Postgres.app捆绑包中的目录.

  • 至于今天bin目录的位置是:/Applications/Postgres.app/Contents/Versions/9.3/bin (2认同)
  • 今天它是`/ Applications/Postgres.app/Contents/Versions/latest/bin` (2认同)

jam*_*ook 24

我正在阅读截至2014年4月的这篇文章,就我的Postgres应用而言,你必须在路径中包含的目录略有不同.

我不得不包括这个:

PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"

我现在可以在终端上运行psql了.


小智 6

在 zsh shell 上进行修改.zshrc

PSQL_PATH="/Applications/Postgres.app/Contents/Versions/latest/bin"
PATH="$PATH:$PSQL_PATH"
Run Code Online (Sandbox Code Playgroud)

根据提示

exec $SHELL
which psql
Run Code Online (Sandbox Code Playgroud)


Ale*_*way 5

你应该做什么使用/ latest而不是版本,所以你不需要在更新Postgres时再次更改它.

如何:http://postgresapp.com/documentation/cli-tools.html

然后运行:

. ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)

重新加载.bash_profile并更新您添加的任何功能.