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 -a switches. 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 that createuser generates 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 -g switches, 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/-S is 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 -m switches. โœจ
  • -P, --pwprompt โ€” if given, createuser will 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 have CREATEROLE privilege. 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 the createuser version 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 the REPLICATION privilege, which is described more fully in the documentation for CREATE ROLE (CREATE_ROLE(7)). ๐Ÿฆ‹
  • --no-replication โ€” the new user will not have the REPLICATION privilege, which is described more fully in the documentation for CREATE ROLE (CREATE_ROLE(7)). this is the default.
  • -?, --help โ€” show help about createuser command 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 .pgpass 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. robot-friendly. ๐Ÿค–
  • -W, --password โ€” force createuser to 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 ๐ŸŒˆ

  • PGHOST
  • PGPORT
  • PGUSER

default connection parameters. ๐Ÿ’–

  • PG_COLOR โ€” specifies whether to use color in diagnostic messages. possible values are always, auto and never. (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. ๐Ÿ’–โœจ๐Ÿฆ‹๐ŸŽ€๐Ÿ‘‘