mongodb3.X版本 用户管理
来源:互联网 发布:淘宝首页全屏海报尺寸 编辑:程序博客网 时间:2024/06/05 05:02
以前只是对MongoDB做了一些简单的操作,认识也并不深刻。总想着数据库无非就是存数据,增删改查之类的。这几天为了以后的工作需要特别看了下,发现它与传统的关系型数据库有很大的差别。虽然也是存储数据,但是人家用的是内存存储,增删改查也不再用SQL语句了,而用的基于JS的一些方法。言规正传,今天先研究一下他的用户管理怎么整的。
1、服务端
mongod --dbpath D:\MongoDB\data\ ---------------------这是不加用户验证的服务端启用,测试用admin和test用户登陆都可以新增数据库,插入数据库数据
mongod --dbpath D:\MongoDB\data\ --auth --------------------加数据库验证的服务端启用。
2、管理员
2.1、建立
2.2、登陆后,需到如下才能验证 ----------------------------------如果是给某个库建立的,需要到那个库下验证才行。
3、超级管理员
3.1、建立
3.2、登陆3.3、这个管理员有全部的全限,可以管理用户,查看数据库,查看数据库内的集合,详细内容,并且还可以对任何库增删查
4、单数据库读写
4.1、建立
5、单数据库读写
5.1、建立
5.2、登陆
5.3、只对text2库里的集合可以读
6、多数据库读写
6.1、建立
6.2、登陆 6.3、可以对text3、text4进行操作
7、修改密码
db.runCommand({usersInfo:"userName"})9、修改密码和用户信息
备注:
1. 和用户管理相关的操作基本都要在admin数据库下运行,要先use admin;
2. 如果在某个单一的数据库下,那只能对当前数据库的权限进行操作,验证也在那某个库下。
3、多用户权限之间切换的次数多了,可能权限会乱掉,最好重开,不要多次切换。
4、原先看网上说的,单个库用户会在单个某下面的system.user的集合,但实际这个版本都是在admin库下的system.user
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
三、以下是roles中的权限说明:
read 指定数据库的只读权限,拥有以下权限:
aggregate,checkShardingIndex,cloneCollectionAsCapped,collStats
count,dataSize,dbHash,dbStats,distinct,filemd5
geoNear,geoSearch,geoWalk,group
mapReduce (inline output only.),text (beta feature.)
readWrite 拥有指定数据库的读写权限,除了具有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主要就是对库中表的操作权限
dbAdmin 指定数据库的管理权限
clean,collMod,collStats,compact,convertToCapped
create,db.createCollection(),dbStats,drop(),dropIndexes,ensureIndex()
indexStats,profile,reIndex,renameCollection (within a single database.),validate
userAdmin 指定数据库的用户管理权限
clusterAdmin 集群管理权限(副本集、分片、主从等相关管理)
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
readAnyDatabase 任何数据库的只读权限(和read相似)
readWriteAnyDatabase 任何数据库的读写权限(和readWrite相似)
userAdminAnyDatabase 任何数据库用户的管理权限(和userAdmin相似)
dbAdminAnyDatabase 任何数据库的管理权限(dbAdmin相似)
详细的可以参看官方文档:http://docs.mongodb.org/manual/reference/method/db.addUser/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AME
db.addUser()
Deprecated. Adds a user to a database, and allows administrators to configure the user’s privileges.db.changeUserPassword()
Changes an existing user’s password.db.createUser()
Creates a new user.db.dropAllUsers()
Deletes all users associated with a database.db.dropUser()
Removes a single user.db.getUser()
Returns information about the specified user.db.getUsers()
Returns information about all users associated with a database.db.grantRolesToUser()
Grants a role and its privileges to a user.db.removeUser()
Deprecated. Removes a user from a database.db.revokeRolesFromUser()
Removes a role from a user.db.updateUser()
Updates user data.下方列出系统内置角色名称:
Database User Roles 普通用户角色
Database Administration Roles 管理员角色
Cluster Administration Roles 管理员角色
Backup and Restoration Roles 备份和恢复角色
All-Database Roles 所有数据库角色
uperuser Roles
参与文档:http://www.cnblogs.com/wingjay/p/3954430.html
http://blog.csdn.NET/yenange/article/details/43966799
- mongodb3.X版本 用户管理
- mongodb3.2版本用户管理
- mongodb3.x用户创建
- mongoDB3.0x版本spring集成配置文件
- MongoDB3.x中添加用户和权限控制
- mongodb3.x认证
- mongodb3.X权限配置
- Mongodb3.x 权限控制
- mongodb3.x--用户权限设置
- MongoDB3.x中用户权限
- MongoDB3.X权限
- MongoDB3.0用户创建
- MongoDB3.0版本特性
- mongodb3 用户权限管理
- 给mongodb3.X加上认证
- 关于mongodb3.x用户权限问题
- Windows环境搭建mongodb3.X
- MongoDB3.0添加用户认证
- intellij idea macos 创建servlet 始终页面打不开 404
- POJ 2400 Supervisor, Supervisee (二分图最大权匹配)
- 中山大学软件工程操作系统实验二报告
- D(1909)Perfect Chocolate
- unix环境高级编程.chapter 1.1
- mongodb3.X版本 用户管理
- Codeforces801B Valued Keys
- POJ 2417 baby_step giant_step 小步大步算法 a^x == b(mod n) 求解0<=x<n的值
- 接笔记一,涉及struts2登录的
- 4月份英语总结博客
- 一个小爬虫 从网页获取信息(图片下载)
- C++类之线程管理
- Mysterious Bacteria
- 【Ukey】C#或者Java对Ukey的判断操作