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
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.
The actual database files will be under /usr/local/var/postgres after you create the database.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With