mongodb 3.2.4 添加用户

db.createUser({user:'superadmin',pwd:'adminmdb', roles:[{role:'root', db:'admin'}]})

db.createUser({user:'user',pwd:'111144', roles:[{role:'dbOwner', db:'xinnetcrm'}]})

db.createUser({user:'mprocessuser',pwd:'444', roles:[{role:'dbOwner', db:'workflow'}]})

db.createUser({user:'ouser',pwd:'444', roles:[{role:'dbOwner', db:'cms'}]})

db.auth("cuser","254")  


db.createUser('cuser''cusers')

2.4:
db.addUser('cecmsmongouser','6wELQSuX795idHbD');
db.auth('cecmsmongouser','6wELQSuX795idHbD');




db.innerprocessdb.insert({"name":"thisis"})
db.T1.insert({"name":"thisis"})
mongo -usupe-p --authenticationDatabase  admin


https://www.runoob.com/mongodb/mongodb-create-database.html

db.grantRolesToUser(
    "mongoinnerprocessuser",
    [
        { role: "readWrite", db: "cs" },
        { role: "dbAdmin", db: "cs" }
    ]
)

cfg={ _id:"middle", members:[ {_id:0,host:'10.0.1.176:27017',priority:20}, {_id:1,host:'72.20.0.22:27017',priority:10},   
    {_id:2,host:'10.20.1.80:27017',arbiterOnly:true}] };
    
rs.initiate(cfg);


上一篇:python函数问题2--3目运算


下一篇:JavaWeb——Ajax与MVC学习总结