溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MongoDB數(shù)據(jù)庫角色的示例分析

發(fā)布時(shí)間:2021-11-11 14:29:30 來源:億速云 閱讀:169 作者:小新 欄目:關(guān)系型數(shù)據(jù)庫

這篇文章給大家分享的是有關(guān)MongoDB數(shù)據(jù)庫角色的示例分析的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

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數(shù)據(jù)庫mms.backup文檔中insert,update權(quán)限

列出所有數(shù)據(jù)庫:listDatabases

列出所有集合索引:listIndexes


對以下提供查詢操作:find

*非系統(tǒng)集合

*系統(tǒng)集合:system.indexes, system.namespaces, system.js

*集合:admin.system.users 和 admin.system.roles

restore

非系統(tǒng)集合、system.js,admin.system.users 和 admin.system.roles 及2.6 版本的system.users提供以下權(quán)限:

collMod,createCollection,createIndex,dropCollection,insert


列出所有數(shù)據(jù)庫:listDatabases

system.users :find,remove,update

All-Database Roles

readAnyDatabase

提供所有數(shù)據(jù)庫中只讀權(quán)限:read

列出集群所有數(shù)據(jù)庫:listDatabases

readWriteAnyDatabase

提供所有數(shù)據(jù)庫讀寫權(quán)限:readWrite

列出集群所有數(shù)據(jù)庫:listDatabases

userAdminAnyDatabase

提供所有用戶數(shù)據(jù)管理權(quán)限:userAdmin

Cluster:authSchemaUpgrade,invalidateUserCache,listDatabases

admin.system.users和admin.system.roles:

collStats,dbHash,dbStats,find,killCursors,planCacheRead

createIndex,dropIndex

dbAdminAnyDatabase

提供所有數(shù)據(jù)庫管理員權(quán)限:dbAdmin

列出集群所有數(shù)據(jù)庫:listDatabases

Superuser Roles

root

角色:dbOwner,userAdmin,userAdminAnyDatabase

readWriteAnyDatabase, dbAdminAnyDatabase,

userAdminAnyDatabase,clusterAdmin

Internal Role

__system

集群中對任何數(shù)據(jù)庫采取任何操作



初始化用戶數(shù)據(jù):

1)管理賬號
use admin
db.createUser({
    user:'admin',
    pwd:'123456',
    roles:[
    {role:'userAdminAnyDatabase',db:'admin'},
    {role:'dbAdminAnyDatabase',db:'admin'},
    {role:'clusterMonitor',db:'admin'}
    ]
})


2)應(yīng)用賬號
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

感謝各位的閱讀!關(guān)于“MongoDB數(shù)據(jù)庫角色的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI