Skip to content

Instantly share code, notes, and snippets.

@ngpestelos
Created February 21, 2014 01:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ngpestelos/9127200 to your computer and use it in GitHub Desktop.
Save ngpestelos/9127200 to your computer and use it in GitHub Desktop.
How to create a postgres account from terminal

Note: Based on this tutorial.

Why

There exists a _postgres account, but I could not switch to it. My solution so far is to create a postgres account to run the PostgreSQL process.

Steps

sudo dscl . -create /Groups/postgres
sudo dscl . -create /Groups/postgres PrimaryGroupID 1000
sudo dscl . -create /Users/postgres
sudo dscl . -create /Users/postgres UserShell /bin/bash
sudo dscl . -create /Users/postgres RealName "PostgreSQL"
sudo dscl . -create /Users/postgres UniqueID "1000"
sudo dscl . -create /Users/postgres PrimaryGroupID 1000
@thierryba
Copy link

my solution for this is to do:
sudo /usr/bin/dscl . -merge Users/_postgres RecordName postgres

but beware that the postgres user does not survive an OS update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment