MongoDB用户及权限管理(一):角色说明

mongodb安装完后默认是不开启auth模块的,普通用户和超级管理员均不通过认证就可操作。当然裸奔有风险,安全起见还是开启auth模块。

首先需要了解下面几点:

1、mongodb是没有默认管理员账号,所以要先添加管理员账号,然后开启权限认证。

2、切换到admin数据库,添加的账号才是管理员账号。

3、用户只能在用户所在数据库登录,包括管理员账号。

4、管理员可以管理所有数据库,但是不能直接管理其他数据库,要先在admin数据库认证后才可以。这一点比较怪。

1.用户权限角色说明

1.1  Database User Roles

  • read

允许用户读取指定数据库

Provides the ability to read data on allnon-system collections and on the following system collections: system.indexes,system.js, and system.namespaces collections.

拥有如下权限:


aggregate,checkShardingIndex,cloneCollectionAsCapped,collStats

count,dataSize,dbHash,dbStats,distinct,filemd5

geoNear,geoSearch,geoWalk,group

mapReduce (inline output only.),text (beta  feature.)

  • readWrite

允许用户读写指定数据库

Provides all the privileges of the readrole and the ability to modify data on all non-system collections and thesystem.js collection.

除了具有read权限,还拥有以下权限:


cloneCollection (as the target  database.),convertToCapped

create (and to create collections implicitly.)

drop(),dropIndexes,emptycapped,ensureIndex()

findAndModify,mapReduce (output to a collection.)

renameCollection (within the same database.)

read和readWrite只要就是对库中表的操作权限

1.2 Database Administration Roles

  • dbAdmin

允许用户在指定数据库中执行管理函数,如索引创建、删除,查看统计或访问system.profile

Provides the ability to performadministrative tasks such as schema-related tasks, indexing, gatheringstatistics. This role does not grant privileges for user and role management.

拥有如下权限:


clean,collMod,collStats,compact,convertToCapped

create,db.createCollection(),dbStats,drop(),dropIndexes,ensureIndex()

indexStats,profile,reIndex,renameCollection  (within a single database.),validate

  • dbOwner

Provides the ability to perform anyadministrative action on the database. This role combines the privilegesgranted by the readWrite, dbAdmin and userAdmin roles.

  • userAdmin

允许用户向system.users集合写入,可以找指定数据库里创建、删除和管理用户

Provides the ability to create and modifyroles and users on the current database. Since the userAdmin role allows usersto grant any privilege to any user, including themselves, the role alsoindirectly provides superuser access to either the database or, if scoped tothe admin database, the cluster.

1.3 Cluster Administration Roles

  • clusterAdmin

只在admin数据库中可用,赋予用户所有分片和复制集相关函数的管理权限。

Provides the greatest cluster-managementaccess. This role combines the privileges granted by the clusterManager,clusterMonitor, and hostManager roles. Additionally, the role provides thedropDatabase action.

拥有如下权限:


addShard,closeAllDatabases,connPoolStats,connPoolSync,_cpuProfilerStart

_cpuProfilerStop,cursorInfo,diagLogging,dropDatabase

enableSharding,flushRouterConfig,fsync,db.fsyncUnlock()

getCmdLineOpts,getLog,getParameter,getShardMap,getShardVersion

hostInfo,db.currentOp(),db.killOp(),listDatabases,listShards

logRotate,moveChunk,movePrimary,netstat,removeShard,unsetSharding

repairDatabase,replSetFreeze,replSetGetStatus,replSetInitiate

replSetMaintenance,replSetReconfig,replSetStepDown,replSetSyncFrom

resync,serverStatus,setParameter,setShardVersion,shardCollection

shardingState,shutdown,splitChunk,splitVector,split,top,touch

  • clusterManager

Provides management and monitoring actionson the cluster. A user with this role can access the config and localdatabases, which are used in sharding and replication, respectively.

  • clusterMonitor

Provides read-only access to monitoringtools, such as the MongoDB Cloud Manager and Ops Manager monitoring agent.

  • hostManager

Provides the ability to monitor and manageservers.

1.4 Backup and Restoration Roles

  • backup

Provides privileges needed to back up data.This role provides sufficient privileges to use the MongoDB Cloud Managerbackup agent, Ops Manager backup agent, or to use mongodump.

  • restore

Provides privileges needed to restore datawith mongorestore without the --oplogReplay option or without system.profilecollection data.

1.5 All-Database Roles

  • readAnyDatabase

只在admin数据库中可用,赋予用户所有数据库的读权限

Provides the same read-only permissions asread, except it applies to all but the local and config databases in thecluster. The role also provides the listDatabases action on the cluster as awhole.

  • readWriteAnyDatabase

只在admin数据库中可用,赋予用户所有数据库的读写权限

Provides the same read and writepermissions as readWrite, except it applies to all but the local and configdatabases in the cluster. The role also provides the listDatabases action onthe cluster as a whole.

  • userAdminAnyDatabase

只在admin数据库中可用,赋予用户所有数据库的userAdmin权限

Provides the same access to useradministration operations as userAdmin, except it applies to all but the localand config databases in the cluster.

Since the userAdminAnyDatabase role allowsusers to grant any privilege to any user, including themselves, the role alsoindirectly provides superuser access.

  • dbAdminAnyDatabase

只在admin数据库中可用,赋予用户所有数据库的dbAdmin权限。

Provides the same access to databaseadministration operations as dbAdmin, except it applies to all but the localand config databases in the cluster. The role also provides the listDatabasesaction on the cluster as a whole.

1.6 Superuser Roles

  • root

只在admin数据库中可用。超级账号,超级权限

Provides access to the operations and allthe resources of the readWriteAnyDatabase, dbAdminAnyDatabase,userAdminAnyDatabase, clusterAdmin, restore, and backup combined.

具体权限可参见:

https://docs.mongodb.com/manual/reference/built-in-roles/#read

时间: 2024-08-24 20:44:32

MongoDB用户及权限管理(一):角色说明的相关文章

MongoDB用户及权限管理(二):用户管理

一.创建管理员账号 下面开始创建一个帐号,该账号需要有grant权限,即:账号管理的授权权限.注意一点,帐号是跟着库走的,所以在指定库里授权,必须也在指定库里验证(auth). > use admin switched to db admin > db.createUser( { user:  "dba", pwd:  "dba", roles:  [ { role: "userAdminAnyDatabase", db: "

MongoDB系列---用户及权限管理02

MongoDB-——Privilege 学习大纲: 1.用户权限管理 2.用户操作 知识回顾:  本系列上一篇博文我们讲述了如何搭建环境以及配置我们的MongoDB,通过搭建环境后我们又学习了如何通过简单的命令和配置来启动关闭我们的MongoDB. 一 用户及权限管理 前言: MongoDB 作为时下最为热门的数据库,那么其安全验证也是必不可少的,否则一个没有验证的数据库暴露出去,任何人可随意操作,这将是非常危险的.我们可以通过使用为MongoDB 创建用户的方式来降低风险 1 MongoDB用

Jenkins2.32用户和权限管理策略

前言 在使用jenkins的过程中,需要为不同的角色分配相应的权限,如果jenkins的用户数据能和公司现在的帐号系统结合起来那会更好. 关于如何为用户分组,我推荐使用 role based authorization strategy 这个插件 我的环境如下: 版本:Jenkins ver. 2.32.3 系统:windows 7 x64 进入用户管理 如果使用的是jenkins内置的用户数据库,操作方法如下: 1.使用管理员帐号登录,选择 Configure Global Security 

对liunx系统中用户和权限管理一点小心得

近期才接触Liunx,给我的感觉,并不是很难,但是知识点很多,命令杂,并且附带了茫茫多的选项.接下来我就拿用户和权限管理来举个例子. 一丶用户&组的创建,管理. 用户,顾名思义,就是在系统上的接口进行操作的人. 用户分为:1.管理员(root)2.普通用户(user):系统用户和登录用户 管理员比较好理解,好比说一个国家的国王,拥有对国家最高的指挥权.root在linux系统中就扮演了国王的角色,任何的权限对它来说都形同虚设. 而普通用户,相当于这个国家的公民,必须遵循国家规定的法律. 普通用户

linux用户及权限管理

[文件管理.管道.用户及组管理.用户及权限管理]\用户及组管理 用户与组管理 Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统.用户的账号一方面可以帮助系统管理员对使用系统的用户进行跟踪,并控制他们对系统资源的访问:另一方面也可以帮助用户组织文件,并为用户提供安全性保护.每个用户账号都拥有一个惟一的用户名和各自的口令.用户在登录时键入正确的用户名和口令后,就能够进入系统和自己的主目录.实现用户账号的管理

第15章 mysql 用户、权限管理

2015-10-24 目录 参考资料 [1] 唐汉明.深入浅出MySQL 数据库开发.优化与管理维护(第2版)[M].北京:人民邮电出版社,2014 [2] Schwartz.高性能MySQL(第3版)[M].北京:电子工业出版社,2013 [3] 范德兰斯.MySQL开发者SQL权威指南 [M].北京:机械工业出版社,2008 [4] Forta.MySQL必知必会 [M].北京:人民邮电出版社,2009 [5] Chapter 6 Security [6] 5.7. MySQL访问权限系统

【linux相识相知】用户及权限管理

linux系统是多用户(Multi-users)和多任务(Multi-tasks)的,这样的目的是为了一台linux主机可以给很多用户提供服务同时运行多种服务,但是我们是怎么区分每个用户呢?作为一个管理员我对linux系统权限有哪些?作为一个普通的用户又可以对linux系统有哪些操作呢?这里就牵扯到了linux的用户类别和权限管理.本次博客就用户和权限管理作出详细的解释. 用户和组类型 在linux系统中,有着用户和组着两个概念,用户是被包含在组里面的. 用户可以分为以下2中类别: 管理员:也就

用户和权限管理

一:用户和组 用户分为两类:一个是管理用户,一个是普通用户, 用户类别:一类是系统用户,另一类是登录用户, 用户的标识是UID,16bit二进制数字是0-65535 管理员:0 普通用户:1-65535 3. 组:一是管理员组,二是普通用户组 4.组类别:一类是系统组,一类是登录组 用户标识GID,管理员组:0普通组:1-65535 5.从用户角度划分: 基本组:每个用户至少有一个组 附加组:同时包括在其他组中 私有组:组名同用户名,且包含一个用户 公共组 :组内包含了对个用户 6.groupa

mysql 用户和权限管理

1.用户连接到 mysql,并作各种查询,对用户权你是谁限的检查1.对于 mysql 你有没有权限连接上来,必须满足下面三个参数:1.你从哪里来?:host 2.你是谁? :user 1.新增一个用户: 命令格式:grant [权限1,权限2,权限3] on *.* to [email protected] identified by password 2.查看一个用户的权限:select * from user where user=root \G; 3.回收权限:revoke [权限] on