DROPUSER(1)
π DROPUSER(1) β ok bestie, let's delete a whole user account β¨
So this is dropuser, like, the PostgreSQL page for it (17.11 documentation era, we're fancy). Buckle up, it's actually not that deep, I promise π«Ά
πΈ NAME πΈ
dropuser β literally removes a PostgreSQL user account. That's it. That's the whole vibe. Poof, gone, no cap π
π¦ SYNOPSIS π¦
dropuser [connection-option...] [option...] [username]
π DESCRIPTION π
Okay so dropuser removes an existing PostgreSQL user. Here's the rules, and listen carefully because this part matters:
- Superusers can use this command to remove any role. Full main character energy, they can do whatever π
- Otherwise? Only non-superuser roles can be removed, and only by a user who has the
CREATEROLEprivilege and has been grantedADMIN OPTIONon the target role. Both. Not one. Both. Periodt.
Also, dropuser is just a wrapper around the SQL command DROP ROLE. There is no effective difference between dropping users via this utility and via other methods for accessing the server. Same thing, different outfit. Slay β¨
π OPTIONS π
dropuser accepts the following command-line arguments:
usernameβ specifies the name of the PostgreSQL user to be removed. If you don't give a name on the command line and you're using-i/--interactive, you'll get prompted for one. So you don't have to remember it, king π«Ά-e,--echoβ echoes the commands thatdropusergenerates and sends to the server. Perfect for when you're nosy and want receipts π-i,--interactiveβ prompts for confirmation before actually removing the user, and prompts for the user name if none is specified on the command line. The "are you sure bestie" button π-V,--versionβ prints thedropuserversion and exits. Quick flex, then bye π--if-existsβ does not throw an error if the user doesn't exist. A notice is issued in this case instead. Very chill, very unbothered π-?,--helpβ shows help aboutdropusercommand line arguments, and exits. Your lil cheat sheet β
π Connection parameter options π
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. And here's the cute lil detail: if the value begins with a slash, it is used as the directory for the Unix domain socket. Sneaky, right? π-pport,--port=portβ specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.-Uusername,--username=usernameβ user name to connect as. And no, bestie, this is not the user name to drop. Read that again. It's who you are, 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, just don't be surprised if it bounces π-W,--passwordβ forcesdropuserto 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. But here's the tea: 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. Efficiency queen behavior π
π§ ENVIRONMENT π§
PGHOSTPGPORTPGUSER
β these are the default connection parameters π
PG_COLORβ specifies whether to use color in diagnostic messages. Possible values arealways,autoandnever. Obviously we're pickingalways, be serious πΈ
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15).
π₯ DIAGNOSTICS π₯
In case of difficulty, go check DROP ROLE (DROP_ROLE(7)) and psql(1) for discussions of potential problems and error messages. Also important: the database server must be running at the targeted host. Like, obviously. And any default connection settings and environment variables used by the libpq front-end library will apply. So if something's weird, it's probably your env vars, ngl π«
π 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;
Look at that confirmation. Iconic. Ate and left no crumbs π
π SEE ALSO π
createuser(1)DROP ROLE(DROP_ROLE(7))
β οΈ Real talk bestie: this permanently removes a user account. There's no undo, no "oopsie", no trash folder. Check your flags, check your target, and if you're nervous, use -i so you get asked first π
β¨ That's the whole page, mwah π β¨
Cute lil sign-off: this glorious document came from the PostgreSQL 17.11 docs, dated 2026, and yes it's the DROPUSER(1) page β you're welcome, go drop responsibly π¦π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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