On this page
dropUser
在本页面
Definition
dropUser
- 从运行命令的数据库中删除用户。 dropUser命令具有以下语法:
{
dropUser: "<user>",
writeConcern: { <write concern> }
}
dropUser命令文档具有以下字段:
Field | Type | Description |
---|---|---|
dropUser |
string | 要删除的用户名。使用用户所在的数据库时,必须发出dropUser命令。 |
writeConcern |
document | 可选的。删除操作的write concern级别。 writeConcern 文档具有与getLastError命令相同的字段。 |
在删除具有userAdminAnyDatabase角色的用户之前,请确保您至少有另一个具有用户 Management 特权的用户。
Required Access
您必须在数据库上具有dropUser action才能从该数据库中删除用户。
Example
mongo shell 中的以下操作序列从products
数据库中删除了reportUser1
:
use products
db.runCommand( {
dropUser: "reportUser1",
writeConcern: { w: "majority", wtimeout: 5000 }
} )