Lion update removed the 'postgres' user. How to restore it?
Asked Answered
K

4

7

I've installed postgres with the kyngchaos installer a couple of months ago. I've now updated to OSX Lion, but the database server fails to start.

A comment on kyngchaos's blog (http://www.kyngchaos.com/blog/2011/20110723_lion) made me look at the 'postgres' user: it doesn't exist anymore! At least, I can't "sudo su postgres" anymore. So I figure that's the reason my server doesn't run.

How can I best restore that user?

Kalikalian answered 25/7, 2011 at 9:32 Comment(3)
Didn't try a reinstall yet as kyngchaos says on his blog that a fresh install also doesn't work yet because of that missing user.Kalikalian
Try adding the user, in this case. And possibly chown -R the relevant folders.Cornaceous
I first had to look up how to add a user in OSX. Linux' "adduser" didn't exist :-)Kalikalian
K
3

(Answering myself)

In the end, the only thing I needed to do was to re-create the "postgres" user. Beforehand, I listed the contents of /usr/local/pgsql/ and saw that for instance the data/ directory was owned by user 101 and group postgres. So I wanted to tie that postgres user to the 101 userid:

sudo dscl . -create /Users/postgres
sudo dscl . -create /Users/postgres UniqueID 101

(And afterwards I restarted my mac as I didn't know how to start that postgres server by hand... ;-)

Kalikalian answered 25/7, 2011 at 11:44 Comment(1)
sudo -u postgres PGDATA=/usr/local/pgsql-9.0/data /usr/local/pgsql-9.0/bin/pg_ctl start to start postgresql without rebooting.Scanderbeg
S
3

I think, in your dscl command, rather than doing a -create, you want to do an -append. Apple tends to prefix underbars to daemon usernames. So Apple probably created a _postgres label for user 101. By doing a -create, you're deleting the default _postgres user, and replacing it with postgres, which could cause other problems down the road. Whereas if you do an -append, then you can user either _postgres or postgres to reference user 101. In any event, you should do a -list before doing either a -create or an -append, just so you know the lay of the land.

Note: I'm still running Snow Leopard, so can't verify that user 101 is indeed _postgres, but I expect Apple is still using the same naming conventions as in Leopard & Snow Leopard, and that's how it should work. Doing a -list will show you what you need to know to confirm my suspicions.

Squarerigger answered 26/7, 2011 at 18:58 Comment(1)
Thanks for the warning. Luckily I did that "-list" beforehand. There was a _postgres user, but that had userid 216 or something, and the userid in my postgres directory was 101. Also, I couldn't "sudo su postgres" anymore, so the postgres-without-underscore user really was gone. I read somewhere that osx now includes postgres out of the box, probably for something internal, so that's probably the underlying reason for the _postgres user.Kalikalian
S
0

I was having a similar problem, and looking through system.log in Console, there were various messages about permissions on the postgresql data directory. I played around with chown and other things, but ended up simply reinstalling - everything is working fine now.

Severn answered 25/7, 2011 at 10:10 Comment(0)
R
0

I did not get a proper user following @Reinout van Rees 's answer on Mountain Lion. These are my steps to get this to work:

  • Download and install Workgroup Manger
  • Login to local ldap: {server: 127.0.01, uname:[your uname], pw: [your pw]}
  • Set View->Show system records to show all accounts
  • Check postgres is not there and there is no other user with id 101.
  • Unlock manager with lock icon
  • Create new user {basic: {name: postgres, userid: 101, pw: None, can_admin_server: False, access_account: False}, advanced: {login_shell: /usr/bin/false}}
  • It gave some weird errors but in the end created my user
  • Test postgres (sudo -u postgres PGDATA=/usr/local/pgsql-9.0/data /usr/local/pgsql-9.0/bin/pg_ctl start)
  • >> Server started
Royceroyd answered 25/4, 2013 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.