PostgreSQL 101: How to create a user account

Very similar to my last post about how to set a user password for a postgres account, here's how to create a user account in the first place.

After you have installed postgres:

$ sudo -u postgres createuser

It'll ask for the username, enter the same as your unix username (the whoami command will tell your username). In my case I entered rory.

Enter name of role to add: rory

Then it'll ask if this should be a super user. I'm not sure what this means, but since this is just an internal playing-around-machine, I pressed y.

Shall the new role be a superuser? (y/n) y

This will then create a postgresl user (or 'role') with the same username as your unix user account. If you start psql when logged in as rory, it'll automatically log you in.

Comments !

blogroll