mongodb 开启身份认证_MongoDB开启安全模式启用身份验证

这篇博客介绍了如何在MongoDB中创建用户,包括管理员和只读用户。使用`db.addUser()`方法添加了名为`admin`、`testadmin`和`testuser`的用户,分别赋予不同级别的权限,`admin`拥有全部权限,`testadmin`无只读权限,而`testuser`则被设定为只读用户。
摘要由CSDN通过智能技术生成

D:\mongodb\bin>mongo localhost/admin

MongoDB shell version: 2.0.6

connecting to: localhost/admin

> db.addUser("admin","666666")

{ "n" : 0, "connectionId" : 1, "err" : null, "ok" : 1 }

{

"user" : "admin",

"readOnly" : false,

"pwd" : "c5436ae68764137eb0a564620d299d0e",

"_id" : ObjectId("5059c7c9efafcf4143548dbb")

}

> use test

switched to db test

> db.addUser("testadmin","666666")

{ "n" : 0, "connectionId" : 1, "err" : null, "ok" : 1 }

{

"user" : "testadmin",

"readOnly" : false,

"pwd" : "6a9f75616b386f43421b1d53e01c1cd1",

"_id" : ObjectId("5059c7f3efafcf4143548dbc")

}

> db.addUser("testuser","666666",true)

{ "n" : 0, "connectionId" : 1, "err" : null, "ok" : 1 }

{

"user" : "testuser",

"readOnly" : true,

"pwd" : "ac9ffa0bb70668810023330e4d3324ec",

"_id" : ObjectId("5059c80aefafcf4143548dbd")

}

>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值