CREATEUSER(1)
๐ CREATEUSER(1) ๐
okay bestie, gather round, because we're about to meet createuser, one of the PostgreSQL 18.6 girlies, and she is so useful. this whole page? it's her manual, and i'm translating it for you. no gatekeeping. ๐
โจ NAME โจ
createuser โ define a new PostgreSQL user account. yes that's literally it. that's the whole job. she makes users. ๐ซถ
โจ SYNOPSIS โจ
createuser [connection-option...] [option...] [username]
look at her. simple. elegant. options and a name. slay.
๐ธ DESCRIPTION ๐ธ
so createuser creates a brand-new PostgreSQL user โ or, being technically correct because we love accuracy here, a role. same thing, cuter name.
here's the vibe check though: only superusers and users with CREATEROLE privilege can create new users. so whoever runs createuser has to be able to connect as a superuser or as someone with CREATEROLE privilege. no sneaking in. ๐
and listen, if you wanna make a role with the SUPERUSER, REPLICATION, or BYPASSRLS privilege, you have to connect as a superuser, not merely with CREATEROLE. that's the rule. fr fr.
๐จ bestie, real talk: being a superuser implies the ability to bypass all access permission checks within the database, so superuser access should not be granted lightly. and CREATEROLE? also conveys very extensive privileges. be stingy with these. i'm serious. ๐ญ
one more thing: createuser is just a wrapper around the SQL command CREATE ROLE. there is no effective difference between creating users via this utility and via other methods for accessing the server. it's the same energy. periodt.
๐ OPTIONS ๐
createuser accepts the following command-line arguments:
usernameโ the name of the PostgreSQL user you wanna create. it must be different from all existing roles in this PostgreSQL installation. no name-stealing, okay? ๐-a role,--with-admin=roleโ names an existing role that gets automatically added as a member of the new role with the admin option, which gives it the right to grant membership in the new role to others. wanna do this with multiple roles? just write multiple-aswitches. stack 'em. โจ-c number,--connection-limit=numberโ set a max number of connections for the new user. default is no limit at all. unlimited. main character energy. ๐-d,--createdbโ the new user will be allowed to create databases. go off. ๐ฅ-D,--no-createdbโ the new user will not be allowed to create databases. this is the default. ๐-e,--echoโ echo the commands thatcreateusergenerates and sends to the server. basically she shows you her work. we love transparency.-E,--encryptedโ this option is obsolete but still accepted for backward compatibility. it's giving vintage. it does nothing new. ๐-g role,--member-of=role,--role=role(deprecated) โ the new role should be automatically added as a member of the specified existing role. multiple existing roles? multiple-gswitches, babe. ๐-i,--inheritโ the new role will automatically inherit privileges of roles it is a member of. this is the default. family inheritance but make it permissions. ๐ง-I,--no-inheritโ the new role will not automatically inherit privileges of roles it is a member of.--interactiveโ prompt for the user name if none is specified on the command line, and also prompt for whichever of the options-d/-D,-r/-R,-s/-Sis not specified on the command line. fun fact: this was the default behavior up to PostgreSQL 9.1. ancient lore. ๐-l,--loginโ 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. she can get in. ๐-L,--no-loginโ the new user will not be allowed to log in. and before you come for me: a role without login privilege is still useful as a means of managing database permissions. she's behind the scenes, pulling strings. ๐-m role,--with-member=roleโ specifies an existing role that will be automatically added as a member of the new role. multiple existing roles? you know the drill, multiple-mswitches. โจ-P,--pwpromptโ if given,createuserwill issue a prompt for the password of the new user. not necessary if you do not plan on using password authentication. optional queen behavior.-r,--createroleโ the new user will be allowed to create, alter, drop, comment on, and change the security label for other roles; that is, this user will haveCREATEROLEprivilege. see role creation for more details about what capabilities are conferred by this privilege. big power. respect it. ๐ซถ-R,--no-createroleโ the new user will not be allowed to create new roles. this is the default.-s,--superuserโ the new user will be a superuser. the ultimate glow-up. ๐-S,--no-superuserโ the new user will not be a superuser. this is the default.-v timestamp,--valid-until=timestampโ set a date and time after which the role's password is no longer valid. default is to set no password expiry date. expiration date, but for passwords. ๐-V,--versionโ print thecreateuserversion and exit. quick lil flex.--bypassrlsโ the new user will bypass every row-level security (RLS) policy. every single one. ๐--no-bypassrlsโ the new user will not bypass row-level security (RLS) policies. this is the default.--replicationโ the new user will have theREPLICATIONprivilege, which is described more fully in the documentation forCREATE ROLE(CREATE_ROLE(7)). ๐ฆ--no-replicationโ the new user will not have theREPLICATIONprivilege, which is described more fully in the documentation forCREATE ROLE(CREATE_ROLE(7)). this is the default.-?,--helpโ show help aboutcreateusercommand line arguments, and exit. the "help me bestie" button. ๐
createuser also accepts the following command-line arguments for connection parameters:
-h host,--host=hostโ 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. cute. โจ-p port,--port=portโ specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.-U username,--username=usernameโ user name to connect as (not the user name to create). read that twice, bestie, it trips people up. ๐ญ-w,--no-passwordโ never issue a password prompt. if the server requires password authentication and a password is not available by other means such as a.pgpassfile, the connection attempt will fail. this option can be useful in batch jobs and scripts where no user is present to enter a password. robot-friendly. ๐ค-W,--passwordโ forcecreateuserto prompt for a password (for connecting to the server, not for the password of the new user).
this option is never essential, since createuser will automatically prompt for a password if the server demands password authentication. however, createuser will waste a connection attempt finding out that the server wants a password. in some cases it is worth typing -W to avoid the extra connection attempt. skip the awkward first knock. ๐ช
๐ ENVIRONMENT ๐
PGHOSTPGPORTPGUSER
default connection parameters. ๐
PG_COLORโ specifies whether to use color in diagnostic messages. possible values arealways,autoandnever. (me, i vote always. obviously. ๐ )
this utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15).
๐ DIAGNOSTICS ๐
in case of difficulty, see CREATE ROLE (CREATE_ROLE(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 connection settings and environment variables used by the libpq front-end library will apply. no cap.
๐ EXAMPLES ๐
to create a user joe on the default database server:
$ createuser joe
to create a user joe on the default database server with prompting for some additional attributes:
$ createuser --interactive joe
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
to create the same user joe using the server on host eden, port 5000, with attributes explicitly specified, taking a look at the underlying command:
$ createuser -h eden -p 5000 -S -D -R -e joe
CREATE ROLE joe NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;
to create the user joe as a superuser, and assign a password immediately:
$ createuser -P -s -e joe
Enter password for new role: xyzzy
Enter it again: xyzzy
CREATE ROLE joe PASSWORD 'SCRAM-SHA-256$4096:44560wPMLfjqiAzyPDZ/eQ==$4CA054rZlSFEq8Z3FEhToBTa2X6KnWFxFkPwIbKoDe0=:L/nbSZRCjp6RhOhKK56GoR1zibCCSePKshCJ9lnl3yw=' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;
in the above example, the new password isn't 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. ๐โจ
๐ SEE ALSO ๐
dropuser(1), CREATE ROLE (CREATE_ROLE(7)), createrole_self_grant
and that's the whole page, bestie!! this was PostgreSQL 18.6, dated 2026, and it's the CREATEUSER(1) manual โ go make some roles, be responsible with superuser, and hydrate. ๐โจ๐ฆ๐๐
๐ฆ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql-libs 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms