1, error procedure, direct Update table
> db.system.users.update ({"_id": ObjectId ("529e67553992b24438d5e315")},{"user": "Tank2", "readOnly": false, "PWD" : "123"})
> Db.system.users.find ();
{"_id": ObjectId ("529e5f8474b4c660718a70f3"), "user": "Tank1", "readOnly": false, "pwd": "35dd47abff098f5b4f0b567db8e Deac5 "}
{" _id ": ObjectId (" 529e67553992b24438d5e315 ")," user ":" Tank2 "," readOnly ": false," pwd ":" 123 "}//This is not right. Had
2, correct approach, using Db.adduser
> Db.adduser (' tank2 ', ', ')
{
"_id": ObjectId ("529e6f1c8d95afd190add450"),
"user": "Tank2",
" ReadOnly ": false,
" pwd ":" 6b4334d2c97c526e6a11b2f9ce1996e0 "
}
Some people will ask, this is not a way to add users. Yes, this is a way to add a user, but if the user name is the same and the password is different, the password is updated.
3, correct approach, using Db.changeuserpassword