关键命令:
db.createUser({user:'coolead',pwd:'coolead',roles:[{role:'dbOwner',db:'mycoolead'}]})
C:\Program Files\MongoDB\Server\3.2\bin>mongo.exe
2016-03-28T10:15:08.979+0800 I CONTROL [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.2.4
connecting to: test
> use mylog
switched to db mylog
> db.createUser({user:'logs',pwd:'coolead',roles:[{role:'dbOwner',db:'mylog'}]})
Successfully added user: {
"user" : "logs",
"roles" : [
{
"role" : "dbOwner",
"db" : "mylog"
}
]
}
>
db.createUser({user:'coolead',pwd:'coolead',roles:[{role:'dbOwner',db:'mycoolead'}]})
C:\Program Files\MongoDB\Server\3.2\bin>mongo.exe
2016-03-28T10:15:08.979+0800 I CONTROL [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.2.4
connecting to: test
> use mylog
switched to db mylog
> db.createUser({user:'logs',pwd:'coolead',roles:[{role:'dbOwner',db:'mylog'}]})
Successfully added user: {
"user" : "logs",
"roles" : [
{
"role" : "dbOwner",
"db" : "mylog"
}
]
}
>