1. 添加用户
2. 带上--auth参数后重启
3. 测试
MongoDB shell version: 1.8.2
connecting to: 127.0.0.1:30000/test
>
> use admin
switched to db admin
> show collections
Sat Aug 6 11:16:45 uncaught exception: error: {
"$err" : "unauthorized db:admin lock type:-1 client:127.0.0.1",
"code" : 10057
}
switched to db admin
> db.auth('admin','admin')
1
> show collections
system.indexes
system.users
>