Apple PostgreSQL

Postgres 9.04 on OS X 10.7 Lion

I installed PostgreSQL on my new MacBook Air today via Homebrew. Having installed it I was mystified why I could not connect without specifically specifying the host was localhost. e.g.

yes:postgres ian$ psql --list
psql: could not connect to server: Permission denied
	Is the server running locally and accepting
	connections on Unix domain socket \
            "/var/pgsql_socket/.s.PGSQL.5432"?

Instead I would have to specify “psql –host=localhost –list”.

Turns out that 10.7 has postgres installed by default (or at least bits of it), but not configured to run. The postgres commands that you type are picked up by the default install as they are first on the path (they are in /usr/bin/, whereas the Homebrew binaries appear in /usr/local/bin/). This posting has more info.

I have changed my previous solution (moving the postgres files out of /usr/bin), which was stupid (and will give similar issues with other Homebrew installs. The correct solution is to amend ~/.bash_profile (create if it doesn’t exist) and add the following line:

export PATH="/usr/local/bin:$PATH"

Start a new terminal and you should be good to go.

Leave a Reply

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