> db.createUser({user:"admin",pwd:"xxxxxxxx",roles:[{role:"userAdminAnyDatabase"}]}) 2016-01-11T17:02:46.417+0800 E QUERY Error: couldn't add user: Missing expected field "db" at Error (<anonymous>) at DB.createUser (src/mongo/shell/db.js:1101:11) at (shell):1:4 at src/mongo/shell/db.js:1101
> show collections 2016-01-11T17:13:37.275+0800 E QUERY Error: listCollections failed: { "ok" : 0, "errmsg" : "not authorized on admin to execute command { listCollections: 1.0 }", "code" : 13 } at Error (<anonymous>) at DB._getCollectionInfosCommand (src/mongo/shell/db.js:646:15) at DB.getCollectionInfos (src/mongo/shell/db.js:658:20) at DB.getCollectionNames (src/mongo/shell/db.js:669:17) at shellHelper.show (src/mongo/shell/utils.js:625:12) at shellHelper (src/mongo/shell/utils.js:524:36) at (shellhelp2):1:1 at src/mongo/shell/db.js:646
$ mongo 192.168.31.101/test -u test -p testtest --authenticationDatabase test MongoDB shell version: 3.0.7 connecting to: 192.168.31.101/test > show collections people > use local switched to db local > show collections startup_log > db.test_coll.insert({"test":"test"}) WriteResult({ "writeError" : { "code" : 13, "errmsg" : "not authorized on local to execute command { insert: \"test_coll\", documents: [ { _id: ObjectId('569374f512032e2e67470c98'), test: \"test\" } ], ordered: true }" } }) > use test switched to db test > db.test_coll.insert({"test":"test"}) WriteResult({ "nInserted" : 1 })