- Reference >
mongo
Shell Methods >- User Management Methods >
- db.dropUser()
db.dropUser()¶
On this page
Definition¶
-
db.
dropUser
(username, writeConcern)¶ Removes the user from the current database.
The
db.dropUser()
method takes the following arguments:Parameter Type Description username
string The name of the user to remove from the database. writeConcern
document Optional. The level of write concern for the removal operation. The writeConcern
document takes the same fields as thegetLastError
command.The
db.dropUser()
method wraps thedropUser
command.Before dropping a user who has the
userAdminAnyDatabase
role, ensure you have at least another user with user administration privileges.
Behavior¶
Replica set¶
If run on a replica set, db.dropUser()
is executed using majority
write concern by default.
Example¶
The following db.dropUser()
operation drops the reportUser1
user on the products
database.