use admin
var schema = db.system.version.findOne({"_id" : "authSchema"})
schema.currentVersion = 3
db.system.version.save(schema)
use admin
db.createUser({user:'root',pwd:'top559383',roles:[{role:'root',db:'admin'}]})
use jg
db.createUser({user:'etl',pwd:'safe*1328',roles:[{role:'dbOwner',db:'jg'}]})
db.createUser({user:'etlquery',pwd:'0000F805F530',roles:[{role:'read',db:'jg'}]})
如果不将authScheme改为3的话,db.auth时候,在后台日志会提示
2015-06-25T15:24:35.019+0800 I ACCESS [conn3] authenticate db: admin { authenticate: 1, nonce: "xxx", user: "root", key: "xxx" }
2015-06-25T15:24:35.021+0800 I ACCESS [conn3] Failed to authenticate root@admin with mechanism MONGODB-CR: AuthenticationFailed MONGODB-CR credentials missing in the user document
MONGODB-CR的代码是3