Postgres 9.4 via Homebrew on macOS

I needed to run an old version of Postgres in order to be supported by the version of Rails I was working with, and I had a new Mac with High Sierra installed. Found out after a bit of “Why doesn’t this postgres formula link its executables?” that it was precisely because of the age of the version that it wasn’t linking. (In my old Linux days I would have just automatically added the PATH or made the link, but I also would have probably rebuilt the Linux install within a few months, anyway.)

# doh this is a keg-only formula. Had to manually link CLI regardless of install method
# run these to set up
brew tap homebrew/versions
brew install homebrew/versions/postgres94
brew services start postgresql@9.4 export
# in your shell's RC file:
PATH=/usr/local/opt/postgresql@9.4/bin:$PATH
LDFLAGS=-L/usr/local/opt/postgresql@9.4/lib
CPPFLAGS=-I/usr/local/opt/postgresql@9.4/include
# For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH=/usr/local/opt/postgresql@9.4/lib/pkgconfig
# -= end shell RC file =-
# do your normal postgresql setup now
initdb
psql

view raw
postgres_setup.sh
hosted with ❤ by GitHub