简体   繁体   English

Postgresql 在 zsh mac 中找不到 psql 命令错误

[英]Postgresql Error in psql command not found in zsh mac

I have installed postgresql on my mac!我已经在我的 mac 上安装了 postgresql!

  • However when I run the command "psql" it says:然而,当我运行命令“psql”时,它说:
zsh: command not found: psql
  • I have located the location of my psql command (with other all postgres commands + pgadmin) and it is in /Users/Library/PostgreSQL/13/bin我找到了我的 psql 命令的位置(以及其他所有 postgres 命令 + pgadmin),它位于 /Users/Library/PostgreSQL/13/bin

  • when I do echo $PATH I get:当我 echo $PATH 我得到:

/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • Now what do I do to run psql without any error?现在我该怎么做才能在没有任何错误的情况下运行 psql?

/Users/Library/PostgreSQL/13/bin is not in your "path" /Users/Library/PostgreSQL/13/bin不在您的“路径”中

Easy solution would be to create a symbolic link for psql in /usr/local/bin/ :简单的解决方案是在/usr/local/bin/中为psql创建一个符号链接:

ln -s /Users/Library/PostgreSQL/13/bin/psql /usr/local/bin/psql

Otherwise you can edit your profile file and extend your path to /Users/Library/PostgreSQL/13/bin否则,您可以编辑您的配置文件并将路径扩展到/Users/Library/PostgreSQL/13/bin

I also had the same issue and a simple solution is to restart the terminal.我也有同样的问题,一个简单的解决方案是重新启动终端。 It gives an opportunity for terminal to reload Postgres.它为终端重新加载 Postgres 提供了机会。

What i did to make it work:我做了什么让它工作:

  1. I didn't have a .zshrc file and created one (peeped here link )我没有.zshrc文件并创建了一个(在此处查看链接

    • Steps for creation:创建步骤:

      • Open Terminal打开终端
      • Type touch ~/.zshrc to create the respective file.键入touch ~/.zshrc以创建相应的文件。 ( touch command will create the .zshrc in your current directory but it will be hidden) touch命令将在您当前目录中创建.zshrc但它将被隐藏)
      • Hit Return点击Return
    • To view/open ~/.zshrc you can do either of two things:要查看/打开~/.zshrc你可以做两件事之一:

      • Open Finder > Press Cmd + Shift + .打开 Finder > 按Cmd + Shift + . (and you will see hidden files) (你会看到隐藏文件)
        my path to the file: Macintosh HD > Users > anatolii =>.zshrc我的文件路径:Macintosh HD > Users > anatolii =>.zshrc

      Or:要么:

      • Open Terminal > and type: open ~/.zshrc打开终端 > 并输入: open ~/.zshrc
  2. Editing .zshrc编辑.zshrc

    • Open .zshrc in editor and pasted this line:在编辑器中打开.zshrc并粘贴此行:
      export PATH=/Library/PostgreSQL/15/bin:$PATH导出 PATH=/Library/PostgreSQL/15/bin:$PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM