small medium large xlarge

04 Dec 2011, 11:19
Patrick Mulder (9 posts)


the installation of Postgres on Mac was not so easy. Maybe others can share experiences.

  • I installed Postgres 9.1 via Homebrew. I had to setup the paths right as explained here:

  • I had to uninstall the default Postgres 8 versions that was on my Mac, similar as discussed here:

  • There were some issues of wrong SHMMAX values, as discussed here:

  • Another problem was setting the permissions right. This discussion helped:

  • Right now, when trying to run psql book -c “SELECT ‘1’::cube;” The cube package seems not to be installed or found. Evt. the brew formula needs to be patches as discussed here:

  • Evt. Installing Postgis instead of Postgres is simpler:

04 Dec 2011, 15:52
Peter Brown (2 posts)

Agreed that it was a PITA. I took a slightly different approach to get the first example working, though I’m not sure whether it’s right or wrong:

Installed Postgres 9.1.1 via Homebrew

# Moved /usr/local/bin to the top of /etc/paths # pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start # createdb book # psql -d book -c “CREATE EXTENSION cube” # psql book -c “SELECT ‘1’::cube;”

I found the CREATE EXTENSION syntax at

04 Dec 2011, 23:15
Patrick Mulder (9 posts)

Short update regarding memory settings:

The binary installer from EntrepriseDB gives some information on the RAM settings:

On a MacBook Pro with 2GB of RAM, the author’s sysctl.conf contains:

kern.sysv.shmmax=1610612736 kern.sysv.shmall=393216 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.maxprocperuid=512 kern.maxproc=2048

Note that (kern.sysv.shmall * 4096) should be greater than or equal to kern.sysv.shmmax. kern.sysv.shmmax must also be a multiple of 4096.

Once you have edited (or created) the file, reboot before continuing with the installation. If you wish to check the settings currently being used by the kernel, you can use the sysctl utility:

% sysctl -a

04 Dec 2011, 23:15
Patrick Mulder (9 posts)

Regarding the createdb command with extensions I get:

psql -d book -c “CREATE EXTENSION cube” psql: warning: extra command-line argument “cube”” ignored psql: FATAL: role “EXTENSION” does not exist

07 Dec 2011, 17:51
Matthew Flower (1 post)

I’m running Mac OS X as well. I went the insanely easy route of using a virtual machine. I ended up using turnkey: (I don’t work for them or anything, it just turned out well for me.)

I installed mine in VMWare Fusion, but their site makes me think that it will work in VirtualBox as well (Parallels? Not sure – probably). I’m sure there are probably other pre-built routes as well.

The only thing that was mildly tricky was figuring out how to install the contrib packages. It turns out that they are in /usr/share/postgresql/8.4/contrib. You do a bunch of things like:

psql -U postgres -W -f cube.sql


and eventually they’ll all be installed.

11 Dec 2011, 17:24
Eric Redmond (21 posts)

Sadly after all these years PostgreSQL is still not easy to install beyond the stock basics.

Over time I want to collect these pain-points and collect them into a series of solid install guide for various OSs - perhaps a series of articles in PragProg!? In any case, I feel your pain, and I had issues of my own, different from those stated above. The variance of problems and solutions was exactly why we couldn’t spend book real-estate on installing each database on each OS – a pattern discovered and established by Bruce Tate in his Seven Languages book.

Thanks (and sorry) for being guinea pigs!

You must be logged in to comment