0

mongos> use admin
switched to db admin
mongos> show dbs
admin 0.000GB
config 0.000GB
mongos> db.createUser({user:’madmin’,pwd:’Sztvis@789′,roles:[{role:’userAdminAnyDatabase’,db:’admin’}]})
Successfully added user: {
“user” : “madmin”,
“roles” : [
{
“role” : “userAdminAnyDatabase”,
“db” : “admin”
}
]
}
mongos> db.auth(‘madmin’,’Sztvis@789′)
1
mongos> sh.addShard(“myreplset01/192.168.1.233:27217,192.168.1.233:27218,192.168.1.233:27219”)
{
“code” : 13,
“ok” : 0,
“errmsg” : “not authorized on admin to execute command { listDatabases: 1, nameOnly: true }”
}

已回答的问题