CREATEUSER(1) PostgreSQL Client Applications CREATEUSER(1)
createuser - define a new PostgreSQL user account
createuser [ option... ] [ username ]
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 can connect as a Post-
Being a superuser also implies the ability to bypass access permission
checks within the database, so superuserdom should not be granted
createuser is a wrapper around the SQL command CREATE USER [cre-
ate_user(7)]. There is no effective difference between creating users
via this utility and via other methods for accessing the server.
createuser accepts the following command-line arguments:
Specifies the name of the PostgreSQL user to be created. This
name must be unique among all PostgreSQL users.
The new user is allowed to create other users. (Note: Actually,
this makes the new user a superuser. The option is poorly
The new user is not allowed to create other users (i.e., the new
user is a regular user, not a superuser). This is the default.
The new user is allowed to create databases.
The new user is not allowed to create databases. This is the
--echo Echo the commands that createuser generates and sends to the
Encrypts the user’s password stored in the database. If not
specified, the default password behavior is used.
Allows you to pick a non-default user ID for the new user. This
is not necessary, but some people like it.
Does not encrypt the user’s password stored in the database. If
not specified, the default password behavior is used.
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
Do not display a response.
You will be prompted for a name and other missing information if it is
not specified on the command line.
createuser also accepts the following command-line arguments for con-
Specifies the host name of the machine on which the server is
running. If the value begins with a slash, it is used as the
directory for the Unix domain socket.
Specifies the TCP port or local Unix domain socket file exten-
sion on which the server is listening for connections.
User name to connect as (not the user name to create).
Force password prompt (to connect to the server, not for the
password of the new user).
PGUSER Default connection parameters
In case of difficulty, see CREATE USER [create_user(7)] and psql(1) for
discussions of potential problems and error messages. The database
server must be running at the targeted host. Also, any default connec-
tion settings and environment variables used by the libpq front-end
library will apply.
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
To create the same user joe using the server on host eden, port 5000,
avoiding the prompts and taking a look at the underlying command:
$ createuser -p 5000 -h eden -D -A -e joe
CREATE USER "joe" NOCREATEDB NOCREATEUSER
dropuser(1), CREATE USER [create_user(7)]
Application 2005-01-17 CREATEUSER(1)
Man(1) output converted with