DROPUSER(1)

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

πŸŽ€ 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/--interactive option is used. so like, it'll ask, but only in that mode πŸ™ˆ
  • -e, --echo β€” echo the commands that dropuser generates 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 the dropuser version 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 about dropuser command line arguments, and exit. the classic πŸŽ€

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. 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 πŸ¦‹
  • -p port, --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 🌈
  • -U username, --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 .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, as long as your .pgpass is sorted πŸ€–
  • -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. lowkey an efficiency hack πŸ’…


🌿 ENVIRONMENT 🌿

  • PGHOST, PGPORT, PGUSER β€” default connection parameters ✨
  • PG_COLOR β€” specifies whether to use color in diagnostic messages. possible values are always, auto and never. 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