DROPUSER(1)
π DROPUSER π
okay bestie, this is the dropuser page from the PostgreSQL 15.19 docs and honestly it's giving "small tool, big power" energy. let's get into it π
πΈ NAME πΈ
dropuser β remove a PostgreSQL user account β¨
β¨ SYNOPSIS β¨
dropuser [connection-option...] [option...] [username]
π DESCRIPTION π
so dropuser removes an existing PostgreSQL user. that's the whole vibe. π₯
but listen β only superusers and users with the CREATEROLE privilege can remove PostgreSQL users. and if you wanna remove a superuser? you gotta be a superuser yourself. no cap, them's the rules π
dropuser is a wrapper around the SQL command DROP ROLE. and like, genuinely β there is no effective difference between dropping users via this utility and via any other method for accessing the server. same energy, different doorway πͺ
π OPTIONS π
dropuser accepts the following command-line arguments:
usernameβ specifies the name of the PostgreSQL user to be removed. you'll get prompted for a name if you didn't specify one on the command line and the-i/--interactiveoption is used. so like, it'll ask, but only in that mode π-e,--echoβ echo the commands thatdropusergenerates and sends to the server. basically "show me your work" energy π-i,--interactiveβ prompt for confirmation before actually removing the user, and prompt for the user name if none is specified on the command line. the "are you sure bestie" flag π«Ά-V,--versionβ print thedropuserversion and exit. quick lil flex β¨--if-existsβ do not throw an error if the user does not exist. a notice is issued in this case. so like, no dramatic meltdown, just a lil heads up π-?,--helpβ show help aboutdropusercommand line arguments, and exit. the classic π
dropuser also accepts the following command-line arguments for connection parameters:
-hhost,--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. yes, a leading slash = socket directory, that's the trick iykyk π¦-pport,--port=port β specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. know your port, love your port π-Uusername,--username=username β user name to connect as (not the user name to drop). okay this one trips everyone up so like β read it twice. it's who you're logging in as, not who's getting deleted π-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. set it and forget it, as long as your.pgpassis sorted π€-W,--passwordβ forcedropuserto prompt for a password before connecting to a database.
this option is never essential, since dropuser will automatically prompt for a password if the server demands password authentication. however, dropuser 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. lowkey an efficiency hack π
πΏ ENVIRONMENT πΏ
PGHOST,PGPORT,PGUSERβ default connection parameters β¨PG_COLORβ specifies whether to use color in diagnostic messages. possible values arealways,autoandnever. make your errors pretty π
this utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15).
π©Ί DIAGNOSTICS π©Ί
in case of difficulty, see DROP ROLE (DROP_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.
fr fr: if something's acting up, check that the server is actually running at the host you targeted before you spiral π
π EXAMPLES π
to remove user joe from the default database server:
$ dropuser joe
to remove user joe using the server on host eden, port 5000, with verification and a peek at the underlying command:
$ dropuser -p 5000 -h eden -i -e joe
Role "joe" will be permanently removed.
Are you sure? (y/n) y
DROP ROLE joe;
see how it asks first? that's the -i doing its lil job, and -e showing you the actual DROP ROLE it ran. iconic behavior honestly π
π¦ SEE ALSO π¦
createuser(1), DROP ROLE (DROP_ROLE(7)) β go make a user, go destroy a user, the circle of life πΈ
and that's the page, bestie π this was PostgreSQL 15.19 documentation, dated 2026, page DROPUSER(1) β slay responsibly, and double-check your -U before you drop anybody πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms