Python 如何使用pymongo命令updateUser

Python 如何使用pymongo命令updateUser,python,linux,mongodb,pymongo-3.x,Python,Linux,Mongodb,Pymongo 3.x,如何使用pymongo命令updateUser 我尝试了以下命令,但没有成功: db.command({'updateUser': 'my_user','update':{'$set':{"pwd":"my_pwd"}}}) 及 返回 pymongo.errors.OperationFailure: Must specify at least one field to update in updateUser 谢谢。python代码正在数据库端执行MongoDB命令“updateUser”。

如何使用pymongo命令updateUser

我尝试了以下命令,但没有成功:

db.command({'updateUser': 'my_user','update':{'$set':{"pwd":"my_pwd"}}})

返回

pymongo.errors.OperationFailure: Must specify at least one field to update in updateUser

谢谢。

python代码正在数据库端执行MongoDB命令“updateUser”。代码中正在执行的命令与中显示的语法不匹配

请尝试以下操作:

db.command( { updateUser: "<username>",
 pwd: "<cleartext new password>",
 roles: [
  // specify any roles assigned to this user. 
 ]
})
db.command({updateUser:“”),
pwd:“,
角色:[
//指定分配给此用户的任何角色。
]
})
该命令将完全替换数据库用户,因此需要在update命令中指定所有角色或权限信息

db.command( { updateUser: "<username>",
 pwd: "<cleartext new password>",
 roles: [
  // specify any roles assigned to this user. 
 ]
})