Creating User to Run Postgres

administratorpostgresqlserveradmin

I'm setting up a postgres server and want to create a separate postgres user to run the process, as recommended in the manual. How do I do this? I installed postgres via Homebrew and have experience with Linux but not much with Macs.

Best Answer

Have you checked to see if it is already there? Most postgres installers will create it for you, and so running grep postgres /etc/passwd will tell you if it exists. Most system accounts on macs start with _, so if you do have to create it, you might consider calling it _postgres, which seems to be common.

The question is similar to question 82472, which should provide what you need to create an account from the command line. There are some useful additional caveats in the comment thread and other answers there. Basically, you use the dscl . create command to create the user in Apple's Directory Services with all of the properties needed to define the user.