6

I installed PostgreSQL via MacPorts. However, going to /opt/local/lib/postgresql84/bin I am unable to execute any of the pg commands. Does anyone know what I am doing wrong?

0

4 Answers 4

20

When you say "going to", it sounds like you're using the cd command to change to that directory. Something like:

$ cd /opt/local/lib/postgresql84/bin
$ psql
psql: command not found

Normally on Unix systems, the current directory is not part of your executable search path. So either explicitly execute psql from the current directory using ./:

$ cd /opt/local/lib/postgresql84/bin
$ ./psql

or, add the directory to your PATH:

$ export PATH=/opt/local/lib/postgresql84/bin:$PATH
$ psql
Sign up to request clarification or add additional context in comments.

Comments

7

I had installed postgres (Mac,The capitan SO) with the dmg and also I got the same issue. I had to install psql through brew. Try with this :

brew install postgres

This worked for me.

Comments

5

Try this command:

find / -name psql

2 Comments

Thanks BarsMonster. I put the paths /opt/local/bin /opt/local/sbin /opt/local/lib/postgresql84/bin in my ~/.bash_profile, and that fixed it. Still not sure why psql didn't work, when I went straight to /opt/local/lib/postgresql84/bin though...
Probably because current directory is not in your "PATH".
2

Try

whereis psql

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.