Mongo创建用户
2015-06-18 14:36
447 查看
列出所有用户
mongo use admin db.system.users.find()
禁用认证模式
/etc/mongod.confnoauth = true
auth = false
创建用户
用户是基于数据库的,在admin数据库上创建的用户属于管理者用户。管理者用户的创建
拥有所有数据库管理权限的用户
use admin db.createUser({ user : "用户名" pwd : "密码" roles : [ { role : "userAdminAnyDatabase" db : "admin" } ] })
特定数据库管理权限的用户
use "数据库名" db.createUser({ user : "用户名", pwd : "密码", roles : [ { role : "userAdmin", db : "数据库名" } ] })
一般用户
db "数据库名" db.createUser({ user : "用户名", pwd : "密码", roles: [ { role : "read", # or "readWrite" db : "数据库名", } ] })
用户验证
db.auth("用户名", "密码")
mongo shell 启动的验证
$ mongo “数据库名” -u “用户名” -p “密码”
删除用户
use "数据库名" db.system.users.remove({user: "要删除的用户名"})
例:创建一个数据库用户,对该数据具有读写权限
创建一个对数据库具有读写权限的数据库用户
use dbname ;
db.createUser({user: “dbuser”, pwd: “dbuseradmin”, roles:[{role: “readWrite”, db: “dbname”}] })
数据库用户登录
mongo dbname -u dbuser -p dbduseradmin
相关文章推荐
- UVALive_6886_Golf Bot(FFT快速傅里叶变换)
- Google I/O 2013:Volley 图片缓存教程
- hdu 1051 (greedy algorithm, how a little modification turn 15ms to 0ms)
- Google对员工到底有多好?
- mongo学习-基础知识
- 20150618-Django之models个人心得
- Google Code Jam 2015 R2 C
- 使用 Google Fonts 为网页添加美观字体
- Google 国内外镜像地址:
- google hacking使用记录
- golang gRPC示例
- Express 4 中如何使用connect-mongo
- VIEWGOOD(远古)在线访谈系统解决方案
- GoF模式
- GO GO GO
- Algorithm --> 矩阵链乘法
- 仿Google相册的侧滑栏效果(DrawerLayout Toolbar)
- CMD中goto语句会中断for循环特性详解
- codeforces 321E Ciel and Gondolas 四边形不等式
- [Machine Learning][inrial lecture] and Category Representation