Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't start Homebrew PostgreSQL install on Mac OS X - "Permission Denied" [closed]

I have a Postgresql installed via Homebrew and after a crash I can not start server anymore..

if I do

 $ pg_ctl start 

I get

pg_ctl: no database directory specified and environment variable PGDATA unset

If I do

$ pg_ctl -D /Library/PostgreSQL/data start

I get

pg_ctl: could not open PID file "/Library/PostgreSQL/data/postmaster.pid": Permission denied

Everything was working just fine and then.. out of the blue, this.

The data folder above has permissions set at "Everything" for postgres user and "None" for everyone..

Path looks fine (in my ~/.bash_profile)

export PATH=/usr/local/bin:$PATH
like image 261
Stpn Avatar asked Jul 15 '12 19:07

Stpn


1 Answers

When you first started Pg, did you let homebrew start it for you, or did you manually start it with pg_ctl ? I ask because I'm guessing you probably need to start and stop Pg using homebrew scripts and/or using launchd rather than directly via pg_ctl. I don't use homebrew (or Mac OS X much) but a quick search suggests that homebrew installs of Pg are usually started and stopped via launchd and ~/Library/LaunchAgents/org.postgresql.postgres.plist .

If you want to manage it manually:

What user does homebrew usually run PostgreSQL as? If you're launching Pg via pg_ctl you need to run it as the right user. From vague memory of other discussion I've seen about homebrew here, it's probably a user named postgres or postgres_ . Double-check using:

ls -ld /Library/PostgreSQL/data

and see what the owning user is, then run:

sudo -u postgres_ pg_ctl -D /Library/PostgreSQL/data start

... replacing "postgres_" with the owner of the datadir.

I suspect the reason you're getting permissions errors is that you probably didn't recursively apply the changes. Please don't; run Pg as the correct user instead.

like image 190
Craig Ringer Avatar answered Sep 30 '22 04:09

Craig Ringer