DROPUSER(1)

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

πŸ’… DROPUSER(1) β€” the "bye bestie" page πŸ’…

okay so this is dropuser, from the PostgreSQL 13.23 documentation, and it's literally the manual page for yeeting a PostgreSQL user account out of existence. buckle up πŸŽ€


✨ NAME ✨

dropuser β€” remove a PostgreSQL user account 🫢


🌸 SYNOPSIS 🌸

dropuser [connection-option...] [option...] [username]

πŸ¦‹ DESCRIPTION πŸ¦‹

dropuser removes an existing PostgreSQL user. that's the whole vibe. πŸ’€

but like β€” permission check, bestie: only superusers and users with the CREATEROLE privilege can remove PostgreSQL users. and if you wanna remove a superuser, you yourself gotta be a superuser. no cap, that's just how it is. πŸ‘‘

dropuser is a wrapper around the SQL command DROP ROLE (DROP_ROLE(7)). and ngl, there is no effective difference between dropping users via this utility and via other methods for accessing the server. same energy, different door. πŸšͺ✨


πŸ’– 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 did use the -i/--interactive option, you'll get prompted for it. πŸ™ˆ
  • -e, --echo β€” echo the commands that dropuser generates and sends to the server. it's giving "show 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 sure" option. 😭
  • -V, --version β€” print the dropuser version and exit. slay, short and sweet.
  • --if-exists β€” do not throw an error if the user does not exist. a notice is issued in this case. so chill. so unbothered. 🌈
  • -?, --help β€” show help about dropuser command line arguments, and exit. the icon of just being helpful. πŸ’…

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. plot twist: if the value begins with a slash, it is used as the directory for the Unix domain socket. 🧚
  • -p port, --port=port β€” specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. pick your door. πŸšͺ
  • -U username, --username=username β€” user name to connect as (not the user name to drop). read that twice bestie, it's a trap. ⚠️
  • -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. lowkey essential for automation. πŸ€–
  • -W, --password β€” force 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. 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. efficiency queen behavior. ⚑


πŸ“ ENVIRONMENT πŸ“

  • PGHOST
  • PGPORT
  • PGUSER

β†’ default connection parameters ✨

  • PG_COLOR β€” specifies whether to use color in diagnostic messages. possible values are always, auto and never. aesthetics matter!! 🎨

this utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 33.14). iykyk. πŸ“š


πŸ’€ 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. so like, check those first 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;

the confirmation prompt said what it said. 🫑


πŸ‘‘ SEE ALSO πŸ‘‘

createuser(1), DROP ROLE (DROP_ROLE(7))


anyway that's the whole page bestie, go forth and drop responsibly πŸ’œβœ¨

PostgreSQL 13.23 Β· 2025 Β· that's the version and date, mwah, bye πŸ’‹πŸŽ€

πŸ“¦ where this page comes from