Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 
like image 673
user3147424 Avatar asked Mar 22 '16 13:03

user3147424


People also ask

Why is psql command not working?

It appears your problem is regarding setting Environment Variables correctly. After installation, the command psql won't work because you need to set the correct PATH to this command in your Environment variables file - which will differ a little according to your version.

Where is psql located Mac?

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


1 Answers

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.

Keywords: Postgresql, PATH, macOS, OSX, psql

like image 79
Mark Setchell Avatar answered Sep 22 '22 19:09

Mark Setchell