macosbashpostgresqlpsql

psql: command not found Mac


I installed PostgreSQL via the graphical install on http://www.postgresql.org/download/macosx/

I see it in my applications and also have the psql terminal in my applications. I need psql to work in the regular terminal for another bash script I'm running for an app.

For some reason, when I run

psql

in the Mac terminal, my output is

-bash: psql: command not found

I ran the following in the terminal:

locate psql | grep /bin

and the output was

/Library/PostgreSQL/9.5/bin/psql

I then edited my ~/.bash_profile and added it to the path like so:

export PATH = /Library/PostgreSQL/9.5/bin/psql:$PATH

The only other thing in ~/.bash_profile is SDK man and it's at the bottom of the script as it says it should be. I've tried setting the bath to just the /Library/PostgreSQL/9.5/bin/ as well. I've restarted my terminal also.

How can I get psql to work?

EDIT After adding to .bashrc, this output is returned when I open terminal

-bash: export: `/Library/PostgreSQL/9.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin': not a valid identifier

Solution

  • You have got the PATH slightly wrong. You need the PATH to "the containing directory", not the actual executable itself.

    Your PATH should be set like this:

    export PATH=/Library/PostgreSQL/9.5/bin:$PATH
    

    without the extra sql part in it. Also, you must remove the spaces around the equals sign.