dropUser

Definition

  • dropUser
  • Removes the user from the database on which you run the command. ThedropUser command has the following syntax:
  1. {
  2. dropUser: "<user>",
  3. writeConcern: { <write concern> }
  4. }

The dropUser command document has the followingfields:

FieldTypeDescriptiondropUserstringThe name of the user to delete. You must issue thedropUser command while using the database where theuser exists.writeConcerndocumentOptional. The level of write concern for theremoval operation. The writeConcern document takes the samefields as the getLastError command.

Before dropping a user who has the userAdminAnyDatabaserole, ensure you have at least another user with user administrationprivileges.

Required Access

You must have the dropUseraction on a database to drop a user from that database.

Example

The following sequence of operations in the mongo shell removesreportUser1 from the products database:

  1. use products
  2. db.runCommand( {
  3. dropUser: "reportUser1",
  4. writeConcern: { w: "majority", wtimeout: 5000 }
  5. } )