创建用户失败
└─[$] <> ./bin/mongo 127.0.0.1:12345/test
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:12345/test
MongoDB server version: 4.0.0
> db.createUser({user:"imooc",pwd:"imooc",roles:[{role:"userAdmin",db:"admin"},{role:"read",db:"test"}]})
2018-07-09T14:35:16.752+0800 E QUERY [js] Error: couldn't add user: not authorized on test to execute command { createUser: "imooc", pwd: "xxx", roles: [ { role: "userAdmin", db: "admin" }, { role: "read", db: "test" } ], digestPassword: true, writeConcern: { w: "majority", wtimeout: 600000.0 }, $db: "test" } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1491:15
@(shell):1:1
>