Take the 2-minute tour ×

Currently I do not have a postgres user.

~$ sudo su - postgres
su: unknown login: postgres

So, I was following these instructions as a quick-start to postgres http://www.sd-kyber.com/library/onlineNotes/psqlOSX.html, but at step 5, where they create the user they refer to the page http://developer.apple.com/internet/opensource/postgres.html, which is a broken link.

What are the steps to create the postgres user? And another question, why does postgres require to have a postgres user? Is it the case that other databases systems require it also?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Lion does come with a postgres user (and even a postgres group), but its name has a "_" prefix (like most system accounts in recent versions of OS X):

$ id _postgres
uid=216(_postgres) gid=216(_postgres) groups=216(_postgres),12(everyone),61(localaccounts)
share|improve this answer
add comment

Postgres requires a user because in Unix all services often have their own user for security reasons. It limits the possibility to take over the whole system if it got breached.

Now OSX Lion comes shipped standard with PgSQL, so there is no reason to install it.

The binary can be found at: /usr/bin/psql or type in the cmd psql -d postgres -U postgres

If that fails, and you have updated your system from Snow Leopard to Lion:


It's a PATH issue. Mac OSX Lion includes Postgresql in the system now. If you do a which psql you'll likely see usr/bin/psql instead of usr/local/bin/psql which is HomeBrew's correct one. If you run brew doctor you should get a message stating that you need to add usr/local/bin to the head of your PATH env variable.

Editing your .bash_profile or .profile, or whichever shell you're using and adding: export PATH=/usr/local/bin:$PATH

as the first export for the PATH then either quit you shell session or source your file with source ~/.bash_profile and it should now be OK again.

You can also edit /etc/paths and make sure /usr/local/bin is on the top.

If for some other reason you still want to add a user:

# dscl / -create /Users/portingunix
# dscl / -create /Users/portingunix UserShell /bin/bash
# dscl / -create /Users/portingunix RealName "Porting Unix 
# dscl / -create /Users/portingunix UniqueID 503
# dscl / -create /Users/portingunix PrimaryGroupID 1000
# dscl / -create /Users/portingunix NFSHomeDirectory /Local/Users/portingunix
# passwd portingunix
share|improve this answer
this fixes a potential problem, but does not answer the oringal question. What are the steps to create the postgres user? –  Doboy Mar 23 '12 at 6:53
updated the answer. –  Lucas Kauffman Mar 23 '12 at 7:02
I'm confused, I thought I had to have a postgres user to use postgres but, by the way you phrase your answer "If for some other reason you still want to add a user:", Changing path variables would solve my problem of not having a postgres user? Please elaborate. –  Doboy Mar 23 '12 at 7:07
Since Lion comes preinstalled with Postgres there is a high chance it has it's own user or is installed in another way. That's why I suggested you try these steps instead of installing another Postgres server on your system. I thought that you wanted to add a custom postgres server of some sorts and that you needed to add a physical user to be able to run the process more securely (UNIX standard). The thing is you use a guide for snow leopard but you are on Lion, that ALREADY has postgres. Why would you want to install postgres a second time? –  Lucas Kauffman Mar 23 '12 at 7:14
add comment

Your Answer


