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?
Best Answer
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:
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:
You can specify the active version like this:
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):
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:
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: