In this recipe we show two ways of creating a new database user, one from the command line, and one using SQL commands.
To create new users, you must either be a superuser or have the
From command line, you run the
creatuser command, and answer a few questions:
pguser@hvost:~$ createuser bob Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) y Shall the new role be allowed to create more new roles? (y/n) n pguser@hvost:~$ createuser tim Shall the new role be a superuser? (y/n) y
createuser is just a shallow wrapper around executing SQL against the database cluster. It connects to database ...