Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MongoDB user Rights Section

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Db.createUser (user,writeConcern)

User this document creates authentication and access information about users

WriteConcern this document describes how to ensure that MongoDB provides a success report for write operations

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

User field, which is the name of the new user

Pwd field, user's password

CusomData field, which is any content, for example, it can be introduced by the user's full name.

The roles field, which specifies the role of the user. An empty array can be used to set an empty role for new users.

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

Built-In Roles (built-in role)

1. Database user roles: read, readWrite

2. Database management role: dbAdmin dbOwner userAdmin

3. Cluster management role: clusterAdmin clusterManager clusterMonitor hostManager

4. Backup recovery role: backup 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 an 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"}]})

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report