0

I'm trying to use psql version 9.6 on Mac OSX 10.11 and installed from the EnterpriseDB installer but I'm getting the following error:

MacBook-Pro:local me$ which psql
/usr/local/bin/psql
MacBook-Pro:local me$ /usr/local/bin/psql -h localhost; echo "Error code: $?"
Usage: /usr/local/bin/psql [wait]
Error code: 127

As you can see, I'm simply trying to connect to localhost and I'm getting a usage error despite following the syntax from the manual.

What is happening here?

s g
  • 5,289
  • 10
  • 49
  • 82

2 Answers2

1

Your bash is returning the error code 127: command not found. See 127 Return code from $? for more details about this bash code. Make sure that psql is in the directory you're trying to access.

Stephane Paquet
  • 2,315
  • 27
  • 31
  • You can find where your psql bin is by issuing the following command in a terminal: whereis psql or which psql. Both command will return the path where psql is – Stephane Paquet Jul 11 '17 at 20:30
  • Right, I added the status code to give a little more info. There doesn't seem to be a PATH issue or anything. I added two more lines in the original post to be more explicit – s g Jul 11 '17 at 20:32
  • I tried your code on my Mac, and I had to explicit the database I connect to by adding --dbame=DATABASE_NAME (I used postgres as there usually is one named like that) – Stephane Paquet Jul 11 '17 at 20:35
1

Simple mistake - /usr/local/bin/psql was a symlink for /Library/PostgreSQL/9.6/scripts/runpsql.sh which doesn't accept any arguments... it's basically EnterpriseDB's shell script wrapper around the actual actual binary which is /Library/PostgreSQL/9.6/bin/psql.

I just needed to point psql to the real executable and not that shell script.

s g
  • 5,289
  • 10
  • 49
  • 82