Mac OS packages. PostgreSQL is the default database on macOS Server as of OS X Server version 10.7. MacOS without the macOS Server add-on installed includes only the PostgreSQL libpq shared library. Induction - Polyglot database client for Mac OSX supporting PostgreSQL, MySQL, SQLite, Redis, and MongoDB out-of-the-box Wynn Netherland Get the latest news and podcasts for developers in your inbox, every week. How to run psql on Mac OS X? Because this is the default location when installing Postgres on a Mac! Bind psql client on specific network interface. Psql, I try to connect to a database and I get “psql: FATAL: Peer authentication failed for user ”, why?

Active1 year, 4 months ago

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?

FreiheitFreiheit
3752 gold badges3 silver badges15 bronze badges

3 Answers

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:

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:

Community
Postgres
user384609user384609

Found the answer at: http://www.istarelworkshop.com/2011/01/04/snow_leopard_development_server_postgresql

Like the general MacPorts installation, the path to PostgreSQL command-line tools is not known to the system, so I append /opt/local/lib/postgresql84/bin in /etc/paths.

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

FreiheitFreiheit
3752 gold badges3 silver badges15 bronze badges

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/:$PATHexport PATH

djjeckdjjeck

Postgres Os X

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

Nice starting point, a few comments/suggestions:

Mac Postgresql Client For Macports

1. When I first make a connection, the application window jumps to full screen size. This is very annoying. I running on a 4k screen with 1:1 pixels, so that is far more real estate than the application needs. Even on smaller screens, I would immediately have to resize the window after I connect.

2. I would like to be able to not provide the database name and allow me to switch from one DB to another using the same connection. (also, currently if you leave DB blank and attempt to connect, it crashes.)

3. 80% of the time I directly connect to my databases with a tool like this, it is not to look at the data, it is to create/drop/modify tables and other design and admin stuff. I'll occasionally use it to test complex queries before putting them in my code, but most of my queries are simple enough that they don't need testing prior to coding. So I'd see this as more useful if it had the ability to simplify the admin stuff. As it is, since I'd need to use pgAdmin 80% of the time, its not compelling to us something else for the other 20%.