Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 type $ which psql nothing is returned. The installation path is /Applications/Postgres93.app. How do I make $ which psql show the correct result?

Mac OS X - Mavericks

PostgreSQL package, I'm not as sure about. I went here and downloaded it - http://postgresapp.com/

like image 481
Don P Avatar asked Jan 05 '14 00:01

Don P


People also ask

Where is psql installed on Mac?

The actual database files will be under /usr/local/var/postgres after you create the database.

Where is psql?

On Windows, you can find psql in the Program Files, and you should be able to launch it in a command prompt simply by clicking on it.

How do you check postgres is installed or not in Mac?

psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres. log 2>&1 & if you want to check and start postgres in one go (handy for automation scripts).


2 Answers

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.

like image 75
Bert Avatar answered Sep 20 '22 17:09

Bert


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.

like image 41
Vick Swift Avatar answered Sep 21 '22 17:09

Vick Swift