-h, --host host
Specifies the host name of the machine on which the server is running. If host begins with a slash, it is used as the directory for the Unix domain socket.
-p, --port port
Specifies the Internet TCP/IP port or local Unix domain socket file extension on which the server is listening for connections.
Echo the queries that createuser generates and sends to the server.
Do not display a response.
The new user is allowed to create databases.
The new user is not allowed to create databases.
The new user is allowed to create other users. (Note: actually, this makes the new user a superuser. The option is poorly named.)
The new user is not allowed to create other users (i.e., the new user is a regular user not a superuser).
If given, createuser will issue a prompt for the password of the new user. This is not necessary if you do not plan on using password authentication.
-i, --sysid uid
Allows you to pick a non-default user id for the new user. This is not necessary, but some people like it.
Encrypts the user's password stored in the database. If not specified, the default is used.
Does not encrypt the user's password stored in the database. If not specified, the default is used.
Specifies the name of the PostgreSQL user to be created. This name must be unique among all PostgreSQL users.
You will be prompted for a name and other missing information if it is not specified on the command line.
The options -h, -p, and -e, are passed on literally to psql(1). The psql options -U and -W are available as well, but their use can be confusing in this context.
All is well.
createuser: creation of user username
Something went wrong. The user was not created.
createuser creates a new PostgreSQL user. Only superusers (users with usesuper set in the pg_shadow table) can create new PostgreSQL users, so createuser must be invoked by someone who is a PostgreSQL superuser.
Being a superuser also implies the ability to bypass access permission checks within the database, so superuser-dom should not be granted lightly.
To create a user joe on the default database server:
$ createuser joe Is the new user allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n CREATE USER
To create the same user joe using the server on host eden, port 5000, avoiding the prompts and taking a look at the underlying query: