Thursday, May 26, 2011

Adding a new user

To create a new Postgres user.
First, create a new Linux user:
sudo useradd -M -N username # (do not create hoMe dir; do not add to group "userName")
sudo passwd username # enter password 'username'

And add user with the same name to Postgres:
psql -h 127.0.0.1 -p 5432 -U username -W -d template1 # insert your hostname and port if different 
In psql:
CREATE USER username WITH PASSWORD 'username';
ALTER USER username CREATEDB; -- allow user to create databases 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.