MongoDB authentication Method (version:3.0.4)

Source: Internet
Author: User
Tags mongodb add robomongo

has been running on this machine, the previous period of time to the background rack to the cloud server, in the settings added username and password, hoping to synchronize the time to modify the settings can be tested locally. Because the cloud server-side database connection needs to be validated, it is also intended to be authenticated locally, and MongoDB is not validated by default. Search on the Internet, methods are relatively old, mainly in the local MongoDB add a user: Into the bin under MongoDB
MongoDB $ cd Bin

Start MongoDB without turning on authentication

Bin $./mongod-dbpath. /blog
Enter the MONGO command to enter the test database
Bin $./mongo
Add Admin user
1 Use admin2 Db.createuser ({3User'Admin',4      pwd:'Admin',5Roles:[{role:'Useradminanydatabase'Db:'Admin'}]6})
Switch to my database (blog for my database name), create a user under my database
1 Use blog2 Db.createuser ({3User'testuser',4      pwd:'Test',5Roles:[{role:'Dbowner'Db:'Blog'}]6})
Restart the server to enable authentication
Bin $./mongod-dbpath. /blog--auth
Login with Robomongo, display authentication Failed, view server log: 2015-08-31t17:39:46.416+0800 I ACCESS [conn46] Failed to authenticate [ Email protected] With mechanism mongodb-cr:authenticationfailed MONGODB-CR credentials missing in the user document to view the documentation, The discovery is because the MongoDB authentication method changes, joined (SCRAM) SHA-1 in the MONGO will just create the user to delete
Use blogdb.dropuser ('testuser')
Turn off verify restart database in MONGO modify the Authschema version of the System.version document to 3 (old version)
1 Use admin 2 db.system.version.update ({'_id':'authschema' },{$set: {'currentversion':3}})3 Db.system.version. Find ()
can see: {"_id": "Authschema", "CurrentVersion": 3}Delete the previously created user,Re-create the user (this time using authentication as MONGODB-CR)
1 Use blog2Db.dropuser ('testuser')3 Db.createuser ({4User'testuser',5      pwd:'Test',6Roles:[{role:'Dbowner'Db:'Blog'}]7})

This time can be successfully landed with Robomongo ~

MongoDB authentication Method (version:3.0.4)

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.