DROPUSER(1)

πŸ“¦ version 17.11, in opensuse-leap 16.0

πŸ’… 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 CREATEROLE privilege and has been granted ADMIN OPTION on 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 that dropuser generates 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 the dropuser version 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 about dropuser command line arguments, and exits. Your lil cheat sheet ⭐

πŸ”Œ Connection parameter options πŸ”Œ

dropuser 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. 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? 🐍
  • -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. 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 .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. Set it and forget it, just don't be surprised if it bounces πŸ’€
  • -W, --password β€” forces dropuser to 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 🧚

  • PGHOST
  • PGPORT
  • PGUSER

β€” these are the default connection parameters πŸ’œ

  • PG_COLOR β€” specifies whether to use color in diagnostic messages. Possible values are always, auto and never. Obviously we're picking always, 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 πŸŽ€


⚠️ 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