Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to install the Posgtres command-line client (typically psql on Linux). I've got postgres installed through MacPorts (postgresql90 and postgresql90-server) but still don't see the client installed.

I have searched MacPorts and am unable to find either the path to the client or a separate port to install it independently.

How can I install the psql command line client?

share|improve this question

Macports packages several versions of PosgreSQL where each version's packages' names contain the version string. So if XY is the concatenation of major and minor PostgreSQL release version (from 8.1 through 9.4 beta as of this writing), the packages are named like this:

  • postgresqlXY (This installs the client, 'psql'.)
  • postgresqlXY-server (This is the server portion.)
  • postgresqlXY-doc (And so on.)

You simply need to activate the installed version of your choice. If you install the package "postgresqlXY" (any version), you also get the package "postgresql_select" as a dependency, which lets you query the active version of postgresql:

$ port select --list postgresql
    Available versions for postgresql:
    none (active)

You can specify the active version like this:

$ port select --set postgresql postgresqlXY
Selecting 'postgresqlXY' for 'postgresql' succeeded. 'postgresqlXY' is now active.

That causes Macports to place a symlink from /opt/local/bin/psql (which is on the path because you installed Macports) to the binary installed at /opt/local/lib/postgresqlXY/bin/psql (which isn't on the path):

$ which psql # That created this symlink to the active version:

Note that you can always access version X.Y of the client binary via /opt/local/bin/psqlXY, which is another symlink Macports maintains for each installed version no matter what is or isn't selected. It was there before you selected version XY, and likewise remains if you select "none" to remove the standard binary name from your path:

$ port select postgresql none
Selecting 'none' for 'postgresql' succeeded. 'none' is now active.
$ which psql   # Not on the path because 'none' is active!
$ which psqlXY # But this is always present:

People end up needing ready access to multiple versions of various pieces of software, and Macports makes that easy by packaging multiple versions of about 50 popular examples using this selection mechanism and corresponding somesoftware_select package as dependency. View the list:

$ port search _select
share|improve this answer
up vote 1 down vote accepted

Found the answer at:

It seems that MacPorts installs the executable but doesn't put it in the path.

share|improve this answer

Make sure you have installed the latest psql client (93 in my example)

sudo port install postgresql93

Then, in your ~/.bash_profile file, add

PATH=/opt/local/lib/postgresql93/bin/:$PATH export PATH

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.