How to put psql on the path when using Postgres.app on OS X?

前端 未结 10 1110
面向向阳花
面向向阳花 2021-02-05 05:01

I\'ve installed Postgres93 on my Mac. I can open the application, and \"Open psql\" through the app which opens up a command line interface with psql.

However, when I ty

相关标签:
10条回答
  • 2021-02-05 05:23

    I had the same problem with nothing showing for the which psql command till I run the command below to resolve it. The command provided below is just a little tweak of what has already been provided by others here. The only difference is, instead of providing a specific postgres version number in the command, you can simply tell postgres to use the latest postgres version by simply running the following command:

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

    And now my terminal was able to find the path to postgres when I run which psql.

    Hope this helps.

    0 讨论(0)
  • 2021-02-05 05:24

    In my case, I installed Postgres12 and had the same issue. I had to look out for the location of my bin folder. It happened to be in /Applications/2ndQuadrant/PostgreSQL/12/bin. So I had to run export PATH="/Applications/2ndQuadrant/PostgreSQL/12/bin:$PATH" in my terminal and restart the terminal. That solved it.

    0 讨论(0)
  • 2021-02-05 05:25

    I just had postgres installed and was not able to run the psql command until I ran the following command in my terminal:

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

    Now the terminal knows where to find postgres when I use the psql command.

    Remember to replace the version number '9.5' with your current version.

    0 讨论(0)
  • 2021-02-05 05:27

    On macOS Mojave these instructions work well:

    1. If your Postgres has not been installed yet, I suggest you use the great "brew" package manager from here https://brew.sh/ :

      $ brew cask install postgres or you can install it usual way from the website

    2. Put this to the bottom of your ~/.bash_profile file:

      export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:${PATH}"

    3. Restart your terminal or restart your ~/.bash_profile directly with the command:

      $ . ~/.bash_profile

    4. Verify your installation:

      $ psql --version

    0 讨论(0)
  • 2021-02-05 05:28

    I'm using catalina 10.15.3 and I had the same issue after installing psql using homebrew. Then I noticed, homebrew mentioned

    ==> libpq libpq is keg-only, which means it was not symlinked into /usr/local, because conflicts with postgres formula.

    If you need to have libpq first in your PATH run:

    echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile

    So, I ran 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile and psql was added to my path

    0 讨论(0)
  • 2021-02-05 05:30

    ** Edited: to include a permanent fix, not just during your current session. **

    I had this same problem, and also found a clear answer lacking in the docs.

    To fix:

    1. Download the new app, and follow the instructions to move it to the Applications folder

    2. Add the new bundle to your path by typing the following in your Terminal (version number specific - mine is 9.4): PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"

    3. To fix the issue on a permanent basis, run the same line but with export in front: export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"

    0 讨论(0)
提交回复
热议问题