1DROPUSER(1)              PostgreSQL 16.1 Documentation             DROPUSER(1)
2
3
4

NAME

6       dropuser - remove a PostgreSQL user account
7

SYNOPSIS

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

DESCRIPTION

12       dropuser removes an existing PostgreSQL user. Superusers can use this
13       command to remove any role; otherwise, only non-superuser roles can be
14       removed, and only by a user who possesses the CREATEROLE privilege and
15       has been granted ADMIN OPTION on the target role.
16
17       dropuser is a wrapper around the SQL command DROP ROLE. There is no
18       effective difference between dropping users via this utility and via
19       other methods for accessing the server.
20

OPTIONS

22       dropuser accepts the following command-line arguments:
23
24       username
25           Specifies the name of the PostgreSQL user to be removed. You will
26           be prompted for a name if none is specified on the command line and
27           the -i/--interactive option is used.
28
29       -e
30       --echo
31           Echo the commands that dropuser generates and sends to the server.
32
33       -i
34       --interactive
35           Prompt for confirmation before actually removing the user, and
36           prompt for the user name if none is specified on the command line.
37
38       -V
39       --version
40           Print the dropuser version and exit.
41
42       --if-exists
43           Do not throw an error if the user does not exist. A notice is
44           issued in this case.
45
46       -?
47       --help
48           Show help about dropuser command line arguments, and exit.
49
50       dropuser also accepts the following command-line arguments for
51       connection parameters:
52
53       -h host
54       --host=host
55           Specifies the host name of the machine on which the server is
56           running. If the value begins with a slash, it is used as the
57           directory for the Unix domain socket.
58
59       -p port
60       --port=port
61           Specifies the TCP port or local Unix domain socket file extension
62           on which the server is listening for connections.
63
64       -U username
65       --username=username
66           User name to connect as (not the user name to drop).
67
68       -w
69       --no-password
70           Never issue a password prompt. If the server requires password
71           authentication and a password is not available by other means such
72           as a .pgpass file, the connection attempt will fail. This option
73           can be useful in batch jobs and scripts where no user is present to
74           enter a password.
75
76       -W
77       --password
78           Force dropuser to prompt for a password before connecting to a
79           database.
80
81           This option is never essential, since dropuser will automatically
82           prompt for a password if the server demands password
83           authentication. However, dropuser will waste a connection attempt
84           finding out that the server wants a password. In some cases it is
85           worth typing -W to avoid the extra connection attempt.
86

ENVIRONMENT

88       PGHOST
89       PGPORT
90       PGUSER
91           Default connection parameters
92
93       PG_COLOR
94           Specifies whether to use color in diagnostic messages. Possible
95           values are always, auto and never.
96
97       This utility, like most other PostgreSQL utilities, also uses the
98       environment variables supported by libpq (see Section 34.15).
99

DIAGNOSTICS

101       In case of difficulty, see DROP ROLE (DROP_ROLE(7)) and psql(1) for
102       discussions of potential problems and error messages. The database
103       server must be running at the targeted host. Also, any default
104       connection settings and environment variables used by the libpq
105       front-end library will apply.
106

EXAMPLES

108       To remove user joe from the default database server:
109
110           $ dropuser joe
111
112       To remove user joe using the server on host eden, port 5000, with
113       verification and a peek at the underlying command:
114
115           $ dropuser -p 5000 -h eden -i -e joe
116           Role "joe" will be permanently removed.
117           Are you sure? (y/n) y
118           DROP ROLE joe;
119

SEE ALSO

121       createuser(1), DROP ROLE (DROP_ROLE(7))
122
123
124
125PostgreSQL 16.1                      2023                          DROPUSER(1)
Impressum