createuser [options...] [username]
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.
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.
Allows the new user to create databases.
Forbids the new user to create databases.
Allows the new user to create other users.
Forbids the new user to create other users.
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.
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. The psql options -U and -W are available as well, but their use can be confusing in this context.
All is well.
Something went wrong. The user was not created.
If there is an error condition, the backend error message will be displayed. See CREATE USER and psql for possibilities.
createuser creates a new PostgreSQL user. Only users with usesuper set in the pg_shadow table can create new PostgreSQL users.
createuser is a shell script wrapper around the SQL command CREATE USER via the PostgreSQL interactive terminal psql. Thus, there is nothing special about creating users via this or other methods. This means that the psql must be found by the script and that a database server is running at the targeted host. Also, any default settings and environment variables available to psql and the libpq front-end library do apply.