MongoDB User Rights Chapter

Source: Internet
Author: User
Tags mongodb

Db.createuser (User,writeconcern)

User This document creates identity authentication and access information about users

Writeconcern This document describes a successful report that ensures that MongoDB provides write operations

The user document, which defines the following form of users:

User field, the name of the new user

PWD field, user's password

Cusomdata field, for any content, such as the user's full name can be introduced

Roles field, specifying the user's role, you can use an empty array to set an empty role for the new user

In the Roles field, you can specify built-in roles and user-defined roles

Built-in Roles (built-in role)

1. Database user role: Read, ReadWrite

2. Database Management role: DbAdmin Dbowner useradmin

3. Cluster Management role: Clusteradmin Clustermanager clustermonitor Hostmanager

4. Backup Recovery role: Restore

5. All database roles: Readanydatabase readwriteanydatabase useradminanydatabase

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

"pwd": "123456",

"CustomData": {"emp": 12343},

roles:[

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

{role: "Readanydatabase", DB: "admin"}, "ReadWrite"]})

1. Add Administrator account

Use admin

Db.createuser ({User: "admin", pwd: "123456", roles:["root"]})

Db.createuser ({User: "admin", pwd: "123456", roles:["root"]})

2. View user Information

Db.system.users.find ()

Db.createuser ({User: "admin", pwd: "admin", Roles:[{role: "Useradminanydatabase", DB: "admin"}])


This article is from the "Dbaspace" blog, make sure to keep this source http://dbaspace.blog.51cto.com/6873717/1976804

MongoDB User Rights Chapter

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.