PostgreSQL command psql not found, trouble adding to $PATH
Here's an approach to take help isolate problems you may have.
Step 1: See if you can add PostgreSQL to your PATH without using Bash dot files.
$ export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH;$ which psql
If this works...
Step 2: Verify that ~\.bash_profile
is being sourced when a new user session is started.
Add the following to the end of your ~/.bash_profile
:
echo "From bash_profile.";
Now restart Terminal.app
or iTerm
and see if that message appears about your prompt.
If this works...
Step 3: Add PATH to ~/.bash_profile
.
In ~/.bash_profile
:
export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH;
Restart your terminal and run:
$ which psql
If you're not seeing:
/Applications/Postgres.app/Contents/MacOS/bin/psql
Then it might be time to scrap trying to install PostgreSQL as a Mac package and use Homebrew.
NOTE: It's psql
and NOT pgsql
.
From the Postgres documentation page:
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
restart your terminal and you will have it in your path.