Operation of user name and password for MongoDB Rights Management

Source: Internet
Author: User
Tags auth mongodb
MongoDB By default is not required to enter a user name and password, customers can log on. But for security reasons, we still have to set the user name and password for it. This article mainly describes the MongoDB Rights Management user name and password operation, I hope to help you.       ad:               This article we introduce MONGODB Rights Management, The main introduction is how to set the user name and password. Let's introduce each of them.       When adding a user, the following two conditions must be met:      1. If you have permission to do so (it will be said later).       2.mongod without--auth (if added, you add permissions   The following occurs).          > use admin            switched to db admin           >  Db.adduser (' sa ', ' sa ')            fri jul 22 14:31:13  uncaught exception: error {           "$err"  :  "unauthorized db:admin lock type:-1 client:127.0.0.1",            "Code"  : 10057          }            >       So when we add a user, we must first add a super  admin without adding--auth.       Service up, enter./mongo.          [root@:/usr/local/mongodb/bin]#./mongo           mongodb shell version: 1.8.2            connecting to: test           > use  admin           switched to db admin            > db.adduser (' sa ', ' sa ')            Fri jul 22 14:34:24 typeerror: db.adduser is not a  function  (shell):1           > db.adduser (' sa ', ' sa ')            {            "_id"  : objectid ("4e2914a585178da4e03a16c3"),            "user"  :  "sa",            "ReadOnly"  : false,           "pwd"  :   "75692b1d11c072c6c79332e248c4f699"           }            >       This shows that   has been established successfully, and then we try the permissions.          > show collections            system.indexes           system.users       without adding--auth   can access the admin favorite default two tables normally.          > db.system. Users.find ()            {  "_id"  : objectid (" 4E2914A585178DA4E03A16C3 "), " user " : " sa ", " readOnly " : false, " pwd " :   "75692b1d11c072c6c79332e248c4f699"  }>      
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.