MongoDB Modify User Password 2 ways _mongodb

Source: Internet
Author: User
Tags mongodb

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.