查看当前数据库的全部用户
> show users
{
"_id" : ObjectId("4dedeeae26e7516d69948e33"),
"user" : "libing",
"readOnly" : false,
"pwd" : "541025c56e577050c3e44efb105e28b6"
}
{
"_id" : ObjectId("4dedeeae26e7516d69948e33"),
"user" : "libing",
"readOnly" : false,
"pwd" : "541025c56e577050c3e44efb105e28b6"
}
> db.system.users.find()
{ "_id" : ObjectId("4dedeeae26e7516d69948e33"), "user" : "libing", "readOnly" : false, "pwd" : "541025c56e577050c3e44efb105e28b6" }
{ "_id" : ObjectId("4dedeeae26e7516d69948e33"), "user" : "libing", "readOnly" : false, "pwd" : "541025c56e577050c3e44efb105e28b6" }
添加用户
> db.addUser("libing","1")
{
"user" : "libing",
"readOnly" : false,
"pwd" : "d9d8e958e0f1d1a0e1a204f85f9ef1b3"
{
"user" : "libing",
"readOnly" : false,
"pwd" : "d9d8e958e0f1d1a0e1a204f85f9ef1b3"
}
> db.addUser("libing","1",true)
{
"user" : "libing",
"readOnly" : true,
"pwd" : "d9d8e958e0f1d1a0e1a204f85f9ef1b3"
{
"user" : "libing",
"readOnly" : true,
"pwd" : "d9d8e958e0f1d1a0e1a204f85f9ef1b3"
}
用户认证
> db.auth("libing","1")
1
1
删除用户
> db.removeUser("libing")