Question

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?

Was it helpful?

Solution

(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... ;-)

OTHER TIPS

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.

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.

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top