MongoDB 2.6.6 Rights Management

Source: Internet
Author: User

MONGODB2.6 's rights management and 2.4 are very different, the Internet can see the basic articles are based on 2.4 below, many do not apply. After some groping finally straightened out 2.6 of the rights management, take notes.

The version I'm using is Linux 64-bit,:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.6.tgz

MongoDB does not enable rights management by default, and access does not require authentication. To turn on the Rights Management feature, increase the--auth parameter at startup.

When enabled, there are no users in the database, and the non-native Client access will prompt for errors

Can only be maintained by native login if the database does not yet have any users

Add an administrator to the database by using the following command. 2.4 and previous versions are used with the AddUser command, after 2.6 with CreateUser.

Use admin

Db.createuser ({"User": "admin",

"pwd": "admin",

"Roles": [{role: ' Useradminanydatabase ', db: ' admin '},

{role: "Dbadminanydatabase", DB: "Admin"}

]

})

It is recommended to switch to the admin library, otherwise the Admin user will be created under another library.

Once you have created the first user, you must also log on to use the database. Logging in with another shell will cause an error.

The client that was already connected is not able to operate.

At this point, you need to log in first, with Db.auth (user, password) command, return 1 for authentication pass.

db.system.users.find () or show users can query to our newly added admin user.

If the Admin user was created in a different library, such as test, then the user who was found should be like this

The differences are in both the _ID and DB fields. When used differently, the database that is validated when the user logs on is displayed. Logging in under the Admin Library is not allowed at this time, you must first switch to the test library.

Once logged in, you can manage any database and user.

Not to be continued ...

?

?

?

MongoDB 2.6.6 Rights Management

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.