I have the following in .bash_profile:

export PATH="/Library/PostgreSQL/9.5/bin/:${PATH}"

I even tried it without the string:

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

I know for sure an executable lives in that bin directory:

$ cd /Library/PostgreSQL/9.5/bin
$ ./psql
psql: FATAL:  password authentication failed for user

However, when I add the path to .bash_profile and then source .bash_profile (and even restart terminal), I get the following:

$ psql
-bash: psql: command not found

What am I doing wrong?

  • How about this: export PATH="/Library/PostgreSQL/9.5/bin/":$PATH ? And then source ~/.bash_profile. – Mateusz Szlosek Mar 25 '16 at 18:50
  • @MateuszSzlosek the exports in the question seem to be ok. – nohillside Mar 25 '16 at 18:53
  • I installed postgresql from here enterprisedb.com/products-services-training/pgdownload#osx All I am trying to do is get psql and other commands recognized from command line. – Donato Mar 25 '16 at 18:54
  • I guess the problem was the order of the export. Adding to the end of the file was only time it worked. – Donato Mar 25 '16 at 18:57
  • Your path statement is actually concatenating a path to the original path. This means your path statement must be on a line after the original path statement, thus why it worked as the last line of the file. – Tyson Mar 26 '16 at 0:57

To add /Library/PostgreSQL/9.5/bin to the path simply add the line:

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

to the file ~/.bash_profile. If you have a second similar line starting with export PATH... try to concatenate them.

After adding then line quit and open Terminal.app or enter source ~/.bash_profile to reload the modified .bash_profile.

Check the path with echo $PATH (which should yield: /Library/PostgreSQL/9.5/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin and the "existence" of psql with which psql: /Library/PostgreSQL/9.5/bin/psql.

Afterwards enter psql -d database_name -U database_user_name with the following result:

Password for user database_user_name: 
psql (9.5.1)
Type "help" for help.


Simply entering psql is as futile as entering mkdir or ssh only.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .