dropAllUsersFromDatabase

On this page本页内容

Definition定义

dropAllUsersFromDatabase

Removes all users from the database on which you run the command.从运行命令的数据库中删除所有用户。

Warning警告

The dropAllUsersFromDatabase removes all users from the database.dropAllUsersFromDatabase从数据库中删除所有用户。

The dropAllUsersFromDatabase command has the following syntax:dropAllUsersFromDatabase命令具有以下语法:

{ dropAllUsersFromDatabase: 1,
  writeConcern: { <write concern> },
  comment: <any>
}

The dropAllUsersFromDatabase document has the following fields:dropAllUsersFromDatabase文档包含以下字段:

Field字段Type类型Description描述
dropAllUsersFromDatabaseintegerSpecify 1 to drop all the users from the current database.指定1以从当前数据库中删除所有用户。
writeConcerndocument

Optional. 可选。The level of write concern for the operation. 操作的写入关注级别。See Write Concern Specification.请参阅写入关注规范。

commentany

Optional. 可选。A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:用户提供了附加到此命令的注释。设置后,此注释将与此命令的记录一起显示在以下位置:

A comment can be any valid BSON type(string, integer, object, array, etc).注释可以是任何有效的BSON类型(字符串、整数、对象、数组等)。

New in version 4.4.在版本4.4中新增

Required Access所需访问权限

You must have the dropUser action on a database to drop a user from that database.必须对数据库执行dropUser操作才能从该数据库中删除用户。

Example示例

The following sequence of operations in mongosh drops every user from the products database:mongosh中的以下操作顺序将每个用户从产品数据库中删除:

use products
db.runCommand( { dropAllUsersFromDatabase: 1, writeConcern: { w: "majority" } } )

The n field in the results document shows the number of users removed:结果文档中的n字段显示删除的用户数:

{ "n" : 12, "ok" : 1 }
←  createUserdropUser →