Home > Database > Mysql Tutorial > MongoDB增加用户认证:增加用户、删除用户、修改用户密码、读写权

MongoDB增加用户认证:增加用户、删除用户、修改用户密码、读写权

WBOY
Release: 2016-06-07 14:53:52
Original
1046 people have browsed it

MongoDB增加用户认证:增加用户、删除用户、修改用户密码、读写权限、只读权限 说明:增加用户是针对数据库进行操作 www.2cto.com 1.进入到数据库 use dbname 2.针对当前数据库添加用户 权限是针对当前数据 1.添加并验证用户 use admin db.addUser(zjx,tsjianx


MongoDB增加用户认证:增加用户、删除用户、修改用户密码、读写权限、只读权限

 

说明:增加用户是针对数据库进行操作    www.2cto.com  

1.进入到数据库 use dbname

2.针对当前数据库添加用户 权限是针对当前数据

1.添加并验证用户

> use admin

> db.addUser("zjx","tsjianxin")

> db.auth("zjx","tsjianxin")
 

2.查看已存在的用户

> db.system.users.find()

3.现在来给另一个数据库51cv配置一个读写权限的用户

> use 51cv

> db.addUser("51cvrw","51cv")

 ..."readOnly" : false...

  www.2cto.com  

4.配置一个只读权限的用户

> use 51cv

> db.addUser("51cvr","51cv",true)

> db.system.users.find()

  ..."readOnly" : true...

5.删除用户

> use dbname (admin or 51cv ,etc)

> db.system.users.remove({user:"haha"})

> db.system.users.find()

6.用户登录数据库测试

for:mongod dbname -u uname -p password

mongo admin -u zjx -p tsjianxin

/usr/local/mongodb/bin/mongo admin -u 用户名 -p  密码 --port 端口号

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template