PostgreSQL permissions issue after upgrading to OS X Lion
Asked Answered
R

3

5

After upgrading to Lion, I get the following error when trying to start up the Postgres server:

pg_ctl: could not open PID file "/usr/local/var/postgres/postmaster.pid": Permission denied

I also tried to re-run the initdb command, but ran into a similar problem:

initdb: could not access directory "/usr/local/var/postgres": Permission denied

If it matters, PostgreSQL was installed via Homebrew. Running brew info postgresql yields the expected results (version, summarized docs).

Ramiah answered 26/7, 2011 at 17:35 Comment(5)
#6771149Devitt
#6814627Defensible
Matt - Yeah, I saw that question, but I don't believe it's a path issue. Running which psql yields /usr/local/bin/psql, which should be the correct Homebrew path. I already have the proper path export set in .bash_login. Also, my issue is with starting the server, not connecting.Ramiah
Those questions don't deal with a "path issue". They deal with a permission issue, because the postgres user got removedTadeo
The first question deals (mostly) with paths, the second with the postgres user being removed. Homebrew seemed to be hosed as well, so I'm going to uninstall/re-install and see if that works.Ramiah
R
8

Well, it turns out the solution was pretty simple. I changed the group on /usr/local/var to staff (from wheel) and changed the ownership (chown -R) to my system account (from root).

After that, postgres started up fine.

I was a little nervous changing those permissions, but the only thing in my /usr/local/var was a postgres directory, so all should be well. If you have other directories/files in /usr/local/var, maybe don't use the -R flag when chown'ing?

The Homebrew ruby installer script changes the group of /usr/local/var to staff, so that must have gotten undone when upgrading to Lion. Not sure about the ownership being root instead of my system account though...

Ramiah answered 27/7, 2011 at 22:7 Comment(1)
just do be sure: you did chgrp -R staff /usr/local/var and chown -R [username here] /usr/local/var, right?Informality
D
0

sudo chown -R $(whoami) /usr/local/var

Donegan answered 18/9, 2020 at 6:20 Comment(0)
S
0

I faced a similar issue, after I've checked I noticed that brew installed postgres on a different path and it is called postgresql@14 (version can be changed).

(used brew & M1 chip)

this made the trick:

pg_ctl -D /opt/homebrew/var/postgresql@14 start
Simpleminded answered 23/3, 2023 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.