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);


posted @ 2021-05-17 13:58  seasonzone  阅读(82)  评论(0编辑  收藏  举报