In this recipe, we will show you two ways of creating a new database user, one with a dedicated command-line utility, and one using SQL commands.
Creating a new user
Getting ready
To create new users, you must either be a superuser or have the CREATEROLE or CREATEROLE privilege.
How to do it...
From the command line, you can run the createuser command:
pguser@hvost:~$ createuser bob
If you add the --interactive command-line option, you activate the interactive mode, which means you will be asked some questions, as follows:
pguser@hvost:~$ createuser --interactive alice...