找不到PostgreSQL命令psql,添加到$ PATH时遇到问题 [英] PostgreSQL command psql not found, trouble adding to $PATH

查看:1053
本文介绍了找不到PostgreSQL命令psql,添加到$ PATH时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将PostgreSQL添加到我的$ PATH变量中.我尝试过此操作以查看psql的位置

I am trying to add PostgreSQL to my $PATH variable. I tried this to see where psql is

whereis psql

对此我没有回应.我确实安装了PostgreSQL.app,所以我从GUI中单击打开psql",它提示终端打开并显示:

To which I got a null response. I do have the PostgreSQL.app installed so I clicked on "Open psql" from the GUI and it prompted the Terminal to open and display:

 /Applications/Postgres.app/Contents/MacOS/bin/psql; exit;

所以我试图将以上内容添加到我的~/.bash_profile中的$PATH变量中(这可能有其自身的问题,因为我不知道是否可以将带有.app扩展名的路径添加到$ PATH中),但是何时我重新启动终端,然后执行echo $PATH | grep Postgres.app我什么都没做.

So I tried to add the above to the $PATH variable in my ~/.bash_profile (which may have its own problems since I don't know if you can add paths with .app extensions to the $PATH) but when I restart my Terminal and do echo $PATH | grep Postgres.app I get nothin'.

推荐答案

这是一种寻求帮助来隔离您可能遇到的问题的方法.

Here's an approach to take help isolate problems you may have.

$ export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH;
$ which psql

如果可行...

~/.bash_profile的末尾添加以下内容:

Add the following to the end of your ~/.bash_profile:

echo "From bash_profile.";

现在重新启动Terminal.appiTerm,然后查看是否出现有关您的提示的消息.

Now restart Terminal.app or iTerm and see if that message appears about your prompt.

如果可行...

~/.bash_profile中:

export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH;

重新启动您的终端并运行:

Restart your terminal and run:

$ which psql

如果您没有看到:

/Applications/Postgres.app/Contents/MacOS/bin/psql

然后可能是时候尝试将PostgreSQL安装为Mac软件包并使用Homebrew了.

Then it might be time to scrap trying to install PostgreSQL as a Mac package and use Homebrew.

注意:它是psql而不是pgsql.

这篇关于找不到PostgreSQL命令psql,添加到$ PATH时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆