MongoDB shell version: 1.8.1
Enter password:
connecting to: test
> show collections;
system.indexes
system.users 建立指定权限用户
MongoDB 也支持为某个特定的数据库来设置用户,如我们为 test 库设一个只读的用户user_reader:
[iyunv@localhost bin]# ./mongo -u root -p
MongoDB shell version: 1.8.1
Enter password:
connecting to: test
> show collections;
system.indexes
system.users
> use test
switched to db test
> db.addUser("user_reader", "user_pwd", true)
{
"user" : "user_reader",
"readOnly" : true,
"pwd" : "0809760bb61ee027199e513c5ecdedc6" }