mongodb的用户和库绑定,访问哪个库,就用哪个用户,这里说一下创建用户的方法.
show dbs
use db_name 这里的db名是cpeducloud2
db.createUser({user:"duser",pwd:"test1mongodb23","roles" : [{"role" : "dbAdmin","db" : "cpeducloud2"},{"role" : "dbOwner","db" : "cpeducloud2"},{"role" : "readWrite","db" : "cpeducloud2"},{"role" : "userAdmin","db" : "cpeducloud2"}],"mechanisms" : ["SCRAM-SHA-1","SCRAM-SHA-256"]});