LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

createuser

PostgreSQL user creation utility

TLDR

Create a user interactively
$ createuser [username]
copy
Create superuser
$ createuser -s [username]
copy
Create user with password prompt
$ createuser -P [username]
copy
Create user that can create databases
$ createuser -d [username]
copy
Create user with connection options
$ createuser -h [localhost] -p [5432] -U [admin] [username]
copy
Create user that can create roles
$ createuser -r [username]
copy
Create user with no login privilege (role only)
$ createuser --no-login [rolename]
copy

SYNOPSIS

createuser [options] [username]

DESCRIPTION

createuser is a PostgreSQL utility that creates new database users (roles). It's a wrapper around the SQL CREATE ROLE command, providing a convenient command-line interface.The tool can create users with various privileges including superuser status, database creation rights, and role creation abilities. It connects to the database server and executes the appropriate SQL.

PARAMETERS

-s, --superuser

Create superuser.
-d, --createdb
Allow creating databases.
-r, --createrole
Allow creating roles.
-l, --login
Allow login (default).
-P, --pwprompt
Prompt for password.
-e, --echo
Show generated SQL.
-h host
Database server host.
-p port
Database server port.
-U user
Connect as user.
-W
Force password prompt.
-i, --inherit
Role inherits privileges (default).
--no-inherit
Role does not inherit privileges of roles it is a member of.
--interactive
Prompt for missing role attributes interactively.
--no-login
Role cannot log in (useful for group roles).
--replication
Allow replication connections.
--no-replication
Role cannot initiate replication (default).
--bypassrls
Allow role to bypass row-level security policies.
--connection-limit n
Maximum concurrent connections for the role (-1 for unlimited).
-V, --version
Print version and exit.

INSTALL

sudo apk add postgresql17-client
copy

CAVEATS

Requires appropriate privileges to create roles. Superuser creation requires superuser connection. Password set via -P is entered interactively.

HISTORY

createuser has been part of PostgreSQL since early versions, providing a shell interface to role management. PostgreSQL evolved from the POSTGRES project at UC Berkeley in the 1980s. The distinction between users and roles was unified in PostgreSQL 8.1.

SEE ALSO

dropuser(1), psql(1), createdb(1), dropdb(1), pg_dump(1), pg_restore(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid