{ mhfs } marcelo silveira

Simple User Management for PostgreSQL

It happened so many times it deserves a self note. PostgreSQL installed and now it’s time to create a new user. Or should I say time to google for the create-user-command-I-never-remember?

To create a new user:

1
CREATE USER your_user WITH PASSWORD 'your_password';

If you want the user to also be able to create databases as you probably want for a local machine user:

1
CREATE USER your_user WITH PASSWORD 'your_password' CREATEDB;

Or you can grant CREATEDB to an existent user:

1
ALTER USER your_user CREATEDB;

And finally, if you want to get rid of an user:

1
DROP USER your_user;

Comments