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

How does mongodb authorize users?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how mongodb authorizes users". In daily operation, I believe many people have doubts about how mongodb authorizes users. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how mongodb authorizes users". Next, please follow the editor to study!

Mongodb user Rights Management:

New user:

Db.createUser (userDocument)

Db.createUser ({user:'backup',pwd:'backup',roles: ["readWrite"]})

Db.createUser ({user: "backup", pwd: "backup", roles: [{role: "readWrite", db: "dba"}]})

Db.createUser ({user: "dba", pwd: "dba", roles: [{role: "dbAdmin", db: "dba"}]})

Built-In Roles (built-in roles):

1. Database user roles: read, readWrite

two。 Database management roles: dbAdmin, dbOwner, userAdmin

3. Cluster management roles: clusterAdmin, clusterManager, clusterMonitor, hostManager

4. Backup and restore roles: backup, restore

5. All database roles: readAnyDatabase, readWriteAnyDatabase, userAdminAnyDatabase, dbAdminAnyDatabase

6. Superuser role: root

/ / there are also several roles that provide access to the system superuser indirectly or directly (dbOwner, userAdmin, userAdminAnyDatabase)

7. Internal role: _ _ system

Read: allows the user to read the specified database

ReadWrite: allows users to read and write to a specified database

DbAdmin: allows users to perform administrative functions in a specified database, such as index creation, deletion, viewing statistics, or accessing system.profile

UserAdmin: allows users to write to the system.users collection. You can create, delete and manage users in a specified database.

ClusterAdmin: available only in the admin database, giving users administrative rights to all shard and replication set related functions.

ReadAnyDatabase: available only in admin databases, giving users read access to all databases

ReadWriteAnyDatabase: available only in admin databases, giving users read and write permissions to all databases

UserAdminAnyDatabase: available only in admin databases, giving users userAdmin permissions for all databases

DbAdminAnyDatabase: available only in admin databases, giving users dbAdmin permissions for all databases.

Root: available only in the admin database. Super account, super privilege

Delete a user:

Db.dropUser (username)

Authorization:

Db.grantRolesToUser (

"backup"

[

{role: "readAnyDatabase", db: "admin"}

]

)

At this point, the study on "how to authorize users by mongodb" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Database

Wechat

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

12
Report