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

Example Analysis of MongoDB Database role

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article shares a sample analysis of MongoDB database roles. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Database User Roles

read

CollStats,dbHash,dbStats,find,killCursors,listIndexes,listCollections

readWrite

CollStats,ConvertToCapped,CreateCollection,DbHash,DbStats,

DropCollection,CreateIndex,DropIndex,Emptycapped,Find,

Insert,KillCursors,ListIndexes,ListCollections,Remove,

RenameCollectionSameDB,update

Database Administration Roles

dbAdmin

collStats,dbHash,dbStats,find,killCursors,listIndexes,listCollections,

dropCollection and createCollection in system.profile

dbOwner

Roles: readWrite, dbAdmin,userAdmin

userAdmin

ChangeCustomData,ChangePassword,CreateRole,CreateUser,

DropRole,DropUser,GrantRole,RevokeRole,ViewRole,viewUser

Cluster Administration Roles

clusterAdmin

Roles: clusterManager, clusterMonitor, hostManager

clusterManager

AddShard,ApplicationMessage,CleanupOrphaned,FlushRouterConfig,

ListShards,RemoveShard,ReplSetConfigure,ReplSetGetStatus,

ReplSetStateChange,Resync,

EnableSharding,MoveChunk,SplitChunk,splitVector

clusterMonitor

connPoolStats,cursorInfo,getCmdLineOpts,getLog,getParameter,

getShardMap,hostInfo,inprog,listDatabases,listShards,netstat,

replSetGetStatus,serverStatus,shardingState,top

collStats,dbStats,getShardVersion

hostManager

applicationMessage,closeAllDatabases,connPoolSync,cpuProfiler,

diagLogging,flushRouterConfig,fsync,invalidateUserCache,killop,

logRotate,resync,setParameter,shutdown,touch,unlock

Backup and Restoration Roles

backup

Provides insert,update permissions in the admin database mms.backup document

List all databases: listDatabases

List all collection indexes: listIndexes

Provide query actions for: find

* Non-systematic collections

* System collection: system.indexes, system.namespaces, system.js

* Collections: admin.system.users and admin.system.roles

restore

Non-system collections, system.js, admin.system.users, and admin.system.roles, as well as version 2.6 of system.users, provide the following permissions:

collMod,createCollection,createIndex,dropCollection,insert

List all databases: listDatabases

system.users :find,remove,update

All-Database Roles

readAnyDatabase

Provides read-only permissions in all databases: read

List all databases in the cluster: listDatabases

readWriteAnyDatabase

Provide all database read and write permissions: readWrite

List all databases in the cluster: listDatabases

userAdminAnyDatabase

Provide all user data management privileges: userAdmin

Cluster:authSchemaUpgrade,invalidateUserCache,listDatabases

admin.system.users and admin.system.roles:

collStats,dbHash,dbStats,find,killCursors,planCacheRead

createIndex,dropIndex

dbAdminAnyDatabase

Provide all database administrator privileges: dbAdmin

List all databases in the cluster: listDatabases

Superuser Roles

root

Roles: dbOwner, userAdmin, userAdminAnyDatabase

readWriteAnyDatabase, dbAdminAnyDatabase,

userAdminAnyDatabase,clusterAdmin

Internal Role

__system

Take any action on any database in the cluster

Initialize user data:

1) Manage Account

use admin

db.createUser({

user:'admin',

pwd:'123456',

roles:[

{role:'userAdminAnyDatabase',db:'admin'},

{role:'dbAdminAnyDatabase',db:'admin'},

{role:'clusterMonitor',db:'admin'}

]

})

2) Application account

use mydb

db.createUser({

user:'mydb',

pwd:'123456',

roles:[{role:"dbOwner",db:"svideo"},

{role:"clusterAdmin",db:"admin"} ]

})

or

use mydb

db.createUser({

user:'mydb',

pwd:'123456',

roles:[{role:'readWrite',db:'svideo'}]

})

Command Line Landing:

mongo 127.0.0.1/svideo -uvdb -p

Or:

mongo --host 47.93.118.56:27017 --authenticationDatabase svideo -u vdb -p

Thank you for reading! About "MongoDB database role example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

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