3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "CREATEUSER" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 createuser \- define a new PostgreSQL user account
33 .HP \w'\fBcreateuser\fR\ 'u
34 \fBcreateuser\fR [\fIconnection\-option\fR...] [\fIoption\fR...] [\fIusername\fR]
40 user (or more precisely, a role)\&. Only superusers and users with
42 privilege can create new users, so
44 must be invoked by someone who can connect as a superuser or a user with
48 If you wish to create a role with the
52 privilege, you must connect as a superuser, not merely with
54 privilege\&. Being a superuser implies the ability to bypass all access permission checks within the database, so superuser access should not be granted lightly\&.
57 very extensive privileges\&.
60 is a wrapper around the
63 \fBCREATE ROLE\fR\&. There is no effective difference between creating users via this utility and via other methods for accessing the server\&.
67 accepts the following command\-line arguments:
71 Specifies the name of the
73 user to be created\&. This name must be different from all existing roles in this
78 \fB\-a \fR\fB\fIrole\fR\fR
80 \fB\-\-with\-admin=\fR\fB\fIrole\fR\fR
82 Specifies an existing role that will be automatically added as a member of the new role with admin option, giving it the right to grant membership in the new role to others\&. Multiple existing roles can be specified by writing multiple
87 \fB\-c \fR\fB\fInumber\fR\fR
89 \fB\-\-connection\-limit=\fR\fB\fInumber\fR\fR
91 Set a maximum number of connections for the new user\&. The default is to set no limit\&.
98 The new user will be allowed to create databases\&.
103 \fB\-\-no\-createdb\fR
105 The new user will not be allowed to create databases\&. This is the default\&.
112 Echo the commands that
114 generates and sends to the server\&.
121 This option is obsolete but still accepted for backward compatibility\&.
124 \fB\-g \fR\fB\fIrole\fR\fR
126 \fB\-\-member\-of=\fR\fB\fIrole\fR\fR
128 \fB\-\-role=\fR\fB\fIrole\fR\fR (deprecated)
130 Specifies the new role should be automatically added as a member of the specified existing role\&. Multiple existing roles can be specified by writing multiple
139 The new role will automatically inherit privileges of roles it is a member of\&. This is the default\&.
144 \fB\-\-no\-inherit\fR
146 The new role will not automatically inherit privileges of roles it is a member of\&.
149 \fB\-\-interactive\fR
151 Prompt for the user name if none is specified on the command line, and also prompt for whichever of the options
155 is not specified on the command line\&. (This was the default behavior up to PostgreSQL 9\&.1\&.)
162 The new user will be allowed to log in (that is, the user name can be used as the initial session user identifier)\&. This is the default\&.
169 The new user will not be allowed to log in\&. (A role without login privilege is still useful as a means of managing database permissions\&.)
172 \fB\-m \fR\fB\fIrole\fR\fR
174 \fB\-\-with\-member=\fR\fB\fIrole\fR\fR
176 Specifies an existing role that will be automatically added as a member of the new role\&. Multiple existing roles can be specified by writing multiple
187 will issue a prompt for the password of the new user\&. This is not necessary if you do not plan on using password authentication\&.
194 The new user will be allowed to create, alter, drop, comment on, change the security label for other roles; that is, this user will have
198 for more details about what capabilities are conferred by this privilege\&.
203 \fB\-\-no\-createrole\fR
205 The new user will not be allowed to create new roles\&. This is the default\&.
212 The new user will be a superuser\&.
217 \fB\-\-no\-superuser\fR
219 The new user will not be a superuser\&. This is the default\&.
222 \fB\-v \fR\fB\fItimestamp\fR\fR
224 \fB\-\-valid\-until=\fR\fB\fItimestamp\fR\fR
226 Set a date and time after which the role\*(Aqs password is no longer valid\&. The default is to set no password expiry date\&.
240 The new user will bypass every row\-level security (RLS) policy\&.
243 \fB\-\-no\-bypassrls\fR
245 The new user will not bypass row\-level security (RLS) policies\&. This is the default\&.
248 \fB\-\-replication\fR
250 The new user will have the
252 privilege, which is described more fully in the documentation for
253 CREATE ROLE (\fBCREATE_ROLE\fR(7))\&.
256 \fB\-\-no\-replication\fR
258 The new user will not have the
260 privilege, which is described more fully in the documentation for
261 CREATE ROLE (\fBCREATE_ROLE\fR(7))\&. This is the default\&.
270 command line arguments, and exit\&.
274 also accepts the following command\-line arguments for connection parameters:
276 \fB\-h \fR\fB\fIhost\fR\fR
278 \fB\-\-host=\fR\fB\fIhost\fR\fR
280 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\&.
283 \fB\-p \fR\fB\fIport\fR\fR
285 \fB\-\-port=\fR\fB\fIport\fR\fR
287 Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections\&.
290 \fB\-U \fR\fB\fIusername\fR\fR
292 \fB\-\-username=\fR\fB\fIusername\fR\fR
294 User name to connect as (not the user name to create)\&.
299 \fB\-\-no\-password\fR
301 Never issue a password prompt\&. If the server requires password authentication and a password is not available by other means such as a
303 file, the connection attempt will fail\&. This option can be useful in batch jobs and scripts where no user is present to enter a password\&.
312 to prompt for a password (for connecting to the server, not for the password of the new user)\&.
314 This option is never essential, since
316 will automatically prompt for a password if the server demands password authentication\&. However,
318 will waste a connection attempt finding out that the server wants a password\&. In some cases it is worth typing
320 to avoid the extra connection attempt\&.
330 Default connection parameters
335 Specifies whether to use color in diagnostic messages\&. Possible values are
342 This utility, like most other
344 utilities, also uses the environment variables supported by
350 In case of difficulty, see
351 CREATE ROLE (\fBCREATE_ROLE\fR(7))
354 for discussions of potential problems and error messages\&. The database server must be running at the targeted host\&. Also, any default connection settings and environment variables used by the
356 front\-end library will apply\&.
361 on the default database server:
367 $ \fBcreateuser joe\fR
375 on the default database server with prompting for some additional attributes:
381 $ \fBcreateuser \-\-interactive joe\fR
382 Shall the new role be a superuser? (y/n) \fBn\fR
383 Shall the new role be allowed to create databases? (y/n) \fBn\fR
384 Shall the new role be allowed to create more new roles? (y/n) \fBn\fR
390 To create the same user
392 using the server on host
393 eden, port 5000, with attributes explicitly specified, taking a look at the underlying command:
399 $ \fBcreateuser \-h eden \-p 5000 \-S \-D \-R \-e joe\fR
400 CREATE ROLE joe NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;
408 as a superuser, and assign a password immediately:
414 $ \fBcreateuser \-P \-s \-e joe\fR
415 Enter password for new role: \fBxyzzy\fR
416 Enter it again: \fBxyzzy\fR
417 CREATE ROLE joe PASSWORD \*(Aqmd5b5f5ba1a423792b526f799ae4eb3d59e\*(Aq SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;
423 In the above example, the new password isn\*(Aqt actually echoed when typed, but we show what was typed for clarity\&. As you see, the password is encrypted before it is sent to the client\&.
425 \fBdropuser\fR(1), CREATE ROLE (\fBCREATE_ROLE\fR(7)), createrole_self_grant