这篇文章给大家分享的是有关MongoDB数据库角色的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
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 和 createCollection 在 system.profile |
dbOwner |
角色:readWrite, dbAdmin,userAdmin |
|
userAdmin |
ChangeCustomData,ChangePassword,CreateRole,CreateUser, DropRole,DropUser,GrantRole,RevokeRole,ViewRole,viewUser |
|
Cluster Administration Roles |
clusterAdmin |
角色: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 |
提供在admin数据库mms.backup文档中insert,update权限 列出所有数据库:listDatabases 列出所有集合索引:listIndexes 对以下提供查询操作:find *非系统集合 *系统集合:system.indexes, system.namespaces, system.js *集合:admin.system.users 和 admin.system.roles |
restore |
非系统集合、system.js,admin.system.users 和 admin.system.roles 及2.6 版本的system.users提供以下权限: collMod,createCollection,createIndex,dropCollection,insert 列出所有数据库:listDatabases system.users :find,remove,update |
|
All-Database Roles |
readAnyDatabase |
提供所有数据库中只读权限:read 列出集群所有数据库:listDatabases |
readWriteAnyDatabase |
提供所有数据库读写权限:readWrite 列出集群所有数据库:listDatabases |
|
userAdminAnyDatabase |
提供所有用户数据管理权限:userAdmin Cluster:authSchemaUpgrade,invalidateUserCache,listDatabases admin.system.users和admin.system.roles: collStats,dbHash,dbStats,find,killCursors,planCacheRead createIndex,dropIndex |
|
dbAdminAnyDatabase |
提供所有数据库管理员权限:dbAdmin 列出集群所有数据库:listDatabases |
|
Superuser Roles |
root |
角色:dbOwner,userAdmin,userAdminAnyDatabase readWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabase,clusterAdmin |
Internal Role |
__system |
集群中对任何数据库采取任何操作 |
初始化用户数据:
1)管理账号
use admin
db.createUser({
user:'admin',
pwd:'123456',
roles:[
{role:'userAdminAnyDatabase',db:'admin'},
{role:'dbAdminAnyDatabase',db:'admin'},
{role:'clusterMonitor',db:'admin'}
]
})
2)应用账号
use mydb
db.createUser({
user:'mydb',
pwd:'123456',
roles:[{role:"dbOwner",db:"svideo"},
{role:"clusterAdmin",db:"admin"} ]
})
或
use mydb
db.createUser({
user:'mydb',
pwd:'123456',
roles:[{role:'readWrite',db:'svideo'}]
})
命令行登陆:
mongo 127.0.0.1/svideo -uvdb -p
或:
mongo –host 47.93.118.56:27017 –authenticationDatabase svideo -u vdb -p
感谢各位的阅读!关于“MongoDB数据库角色的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/205545.html