MongoDB C # connection error Invalid credentials for database ' admin '

Source: Internet
Author: User
Tags auth

This 2 days learning mongodb3.2.9, the user set up, the results in C # query when the error, to see the literal meaning of the user verification did not pass, but I use the shell is completely no problem, and then the Internet search, found that I used the old driver, the old driver is the old check mode, And mongodb3.2.9 is using the new scram-sha-1 check, so the verification will not pass

My side because of the software environment problems and want to continue to use the old drive, it needs to be in MongoDB to change the calibration method

First, turn off the Auth authentication start service first

D:
CD D:\MongoDB\Server\3.2\bin
Mongod--dbpath D:\mongodb\data

And then Modify the System.version Authschema CurrentVersion is 3, the default is 5 (without creating a user version is null, create a user version is created, this time the user's authentication method is the default 5, so it is to be deleted)

> Use admin
Switched to DB admin
> var s= db.system.version.findOne ({"_id": "Authschema"})
> s.currentversion = 3
3
> Db.system.version.save (s)
Writeresult ({"nmatched": 1, "nupserted": 0, "nmodified": 1})

This time the verification method is modified, and then the user to create the authentication method will become 3.

>use Admin>db.createuser ({User: "admin", pwd: "admin", Roles:[{role: "Root", DB: "admin"}]) Finally, start the service with Auth, Can be verified with the old driver D:
CD D:\MongoDB\Server\3.2\bin
Mongod--dbpath D:\mongodb\data -auth

MongoDB C # connection error Invalid credentials for database ' admin '

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.