Fix Postgres permission denied issue on OSX Lion

The good thing is that Apple decides to bundle PostgresSQL 8.4 with OSX Lion which cause conflict if you install Postgres 9.x using brew or Macport. You will likely bump into following error:

    $ psql -d postgres -U postgres
    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"? 

So what’s going wrong here? Because the stock postgresql has higher precedence in PATH.

To fix this, simply make /usr/local/bin highest precendence for $PATH.

Local scope (recommended):
Edit ~/.bash_profile

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

System-wide scope:
Edit your /etc/paths and move your /usr/local/bin to the top.

$ sudo nano /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
Advertisements

About Jones Lee

Nothing much about me..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: