Pg_dump on MacOS without Postgresql

You could also use homebrew to install libpq.

brew install libpq

On Mac M1

arch -arm64 brew install libpq

This would give you psql, pg_dump and a whole bunch of other client utilities without installing Postgres.

Unfortunately since it provides some of the same utilities as are included in the full postgresql package, brew installs it “keg-only” which means it isn’t in the PATH by default. Homebrew will spit out some information on how to add it to your PATH after installation. In my case it was this:

echo 'export PATH="/opt/homebrew/Cellar/libpq/13.3/bin:$PATH"' >> ~/.zshrc

Alternatively, you can create symlinks for the utilities you need. E.g.:

ln -s /opt/homebrew/Cellar/libpq/13.3/bin/psql /usr/local/bin/psql

Note: used installed version instead of 13.3.

Alternatively, you could instruct homebrew to “link all of its binaries to the PATH anyway”

brew link --force libpq

but then you’d be unable to install the postgresql package later.

Found solutions at

Leave a Reply

Your email address will not be published. Required fields are marked *