Mongodb authorized users to manage Add users

Source: Internet
Author: User
Tags mongodb add

"The development process of the essay summary, you are welcome to review, you can do more rigorous "

Introduction:MongoDB NoSQL Database Document type database

A few days ago, to do a log collation of the project when the persistent storage with MongoDB to prevent MongoDB without permission to link, added permission verification

1 if MongoDB is an open intranet address, don't worry about external links

2 MongoDB Add Users (version MongoDB 3.2.7)

    • Licensing method to start a service

To allow the user to take effect , specify the--auth option when the server needs to be started .

    • Authorization before manipulating MongoDB

Db.auth (' root ', ' password ')

    • Create a database
1 MONGO Create a database is an implicitly created use Usertest (delete db.dropdatabase ()) 2 db.createcollection (' TestTable '). Collection can also be created implicitly (Db.testTable.drop ())
    • Create user
Useradmin, Roles is clusteradmin and readanydatabase and read and write ReadWrite

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

"pwd": "Password",

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

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

"ReadWrite"

] },

{w: "Majority", wtimeout:5000})

Delete User Db.dropuser (' natureadmin ')
    • Authorized completion

Db.auth (' useradmin ', ' password ')

End

Mongodb authorized users to manage Add users

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.