{
    "mode": "man",
    "parameter": "DROPUSER",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/man/DROPUSER/json",
    "generated": "2026-11-10T03:04:05Z",
    "synopsis": "dropuser [connection-option...] [option...] [username]",
    "sections": {
        "NAME": {
            "content": "dropuser - remove a PostgreSQL user account\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "dropuser [connection-option...] [option...] [username]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "dropuser removes an existing PostgreSQL user. Superusers can use this command to remove any\nrole; otherwise, only non-superuser roles can be removed, and only by a user who possesses\nthe CREATEROLE privilege and has been granted ADMIN OPTION on the target role.\n\ndropuser is a wrapper around the SQL command DROP ROLE. There is no effective difference\nbetween dropping users via this utility and via other methods for accessing the server.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "dropuser accepts the following command-line arguments:\n\nusername\nSpecifies the name of the PostgreSQL user to be removed. You will be prompted for a name\nif none is specified on the command line and the -i/--interactive option is used.\n",
            "subsections": [
                {
                    "name": "-e",
                    "content": "",
                    "flag": "-e"
                },
                {
                    "name": "--echo",
                    "content": "Echo the commands that dropuser generates and sends to the server.\n",
                    "long": "--echo"
                },
                {
                    "name": "-i",
                    "content": "",
                    "flag": "-i"
                },
                {
                    "name": "--interactive",
                    "content": "Prompt for confirmation before actually removing the user, and prompt for the user name\nif none is specified on the command line.\n",
                    "long": "--interactive"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                },
                {
                    "name": "--version",
                    "content": "Print the dropuser version and exit.\n",
                    "long": "--version"
                },
                {
                    "name": "--if-exists",
                    "content": "Do not throw an error if the user does not exist. A notice is issued in this case.\n\n-?",
                    "long": "--if-exists"
                },
                {
                    "name": "--help",
                    "content": "Show help about dropuser command line arguments, and exit.\n\ndropuser also accepts the following command-line arguments for connection parameters:\n",
                    "long": "--help"
                },
                {
                    "name": "-h",
                    "content": "--host=host\nSpecifies the host name of the machine on which the server is running. If the value\nbegins with a slash, it is used as the directory for the Unix domain socket.\n",
                    "flag": "-h"
                },
                {
                    "name": "-p",
                    "content": "--port=port\nSpecifies the TCP port or local Unix domain socket file extension on which the server is\nlistening for connections.\n",
                    "flag": "-p"
                },
                {
                    "name": "-U",
                    "content": "--username=username\nUser name to connect as (not the user name to drop).\n",
                    "flag": "-U"
                },
                {
                    "name": "-w",
                    "content": "",
                    "flag": "-w"
                },
                {
                    "name": "--no-password",
                    "content": "Never issue a password prompt. If the server requires password authentication and a\npassword is not available by other means such as a .pgpass file, the connection attempt\nwill fail. This option can be useful in batch jobs and scripts where no user is present\nto enter a password.\n",
                    "long": "--no-password"
                },
                {
                    "name": "-W",
                    "content": "",
                    "flag": "-W"
                },
                {
                    "name": "--password",
                    "content": "Force dropuser to prompt for a password before connecting to a database.\n\nThis option is never essential, since dropuser will automatically prompt for a password\nif the server demands password authentication. However, dropuser will waste a connection\nattempt finding out that the server wants a password. In some cases it is worth typing -W\nto avoid the extra connection attempt.\n",
                    "long": "--password"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "PGHOST\nPGPORT\nPGUSER\nDefault connection parameters\n\nPGCOLOR\nSpecifies whether to use color in diagnostic messages. Possible values are always, auto\nand never.\n\nThis utility, like most other PostgreSQL utilities, also uses the environment variables\nsupported by libpq (see Section 34.15).\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "In case of difficulty, see DROP ROLE (DROPROLE(7)) and psql(1) for discussions of potential\nproblems and error messages. The database server must be running at the targeted host. Also,\nany default connection settings and environment variables used by the libpq front-end library\nwill apply.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To remove user joe from the default database server:\n\n$ dropuser joe\n\nTo remove user joe using the server on host eden, port 5000, with verification and a peek at\nthe underlying command:\n\n$ dropuser -p 5000 -h eden -i -e joe\nRole \"joe\" will be permanently removed.\nAre you sure? (y/n) y\nDROP ROLE joe;\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "createuser(1), DROP ROLE (DROPROLE(7))\n\nPostgreSQL 16.14                                2026                                     DROPUSER(1)",
            "subsections": []
        }
    },
    "summary": "dropuser - remove a PostgreSQL user account",
    "flags": [
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--echo",
            "arg": null,
            "description": "Echo the commands that dropuser generates and sends to the server."
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--interactive",
            "arg": null,
            "description": "Prompt for confirmation before actually removing the user, and prompt for the user name if none is specified on the command line."
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Print the dropuser version and exit."
        },
        {
            "flag": "",
            "long": "--if-exists",
            "arg": null,
            "description": "Do not throw an error if the user does not exist. A notice is issued in this case. -?"
        },
        {
            "flag": "",
            "long": "--help",
            "arg": null,
            "description": "Show help about dropuser command line arguments, and exit. dropuser also accepts the following command-line arguments for connection parameters:"
        },
        {
            "flag": "-h",
            "long": null,
            "arg": null,
            "description": "--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."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "--port=port Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections."
        },
        {
            "flag": "-U",
            "long": null,
            "arg": null,
            "description": "--username=username User name to connect as (not the user name to drop)."
        },
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--no-password",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-W",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--password",
            "arg": null,
            "description": "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."
        }
    ],
    "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_also": [
        {
            "name": "createuser",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/createuser/1/json"
        },
        {
            "name": "DROPROLE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPROLE/7/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Remove an existing PostgreSQL user (role).",
        "examples": [
            {
                "description": "Prompt for confirmation and the username before user removal",
                "command": "dropuser {{-i|--interactive}}"
            },
            {
                "description": "Remove user instantly",
                "command": "dropuser {{username}}"
            },
            {
                "description": "No error if the user to be removed doesn't exist",
                "command": "dropuser --if-exists {{username}}"
            },
            {
                "description": "Remove a user on the server with address 127.0.0.1 on port 4321",
                "command": "dropuser {{-h|--host}} 127.0.0.1 {{-p|--port}} 4321 {{username}}"
            },
            {
                "description": "Remove a user on the server with address 127.0.0.1 on port 4321 as user \"admin\"",
                "command": "dropuser {{-U|--username}} admin {{-h|--host}} 127.0.0.1 {{-p|--port}} 4321 {{username}}"
            }
        ]
    }
}