数据库
首页 > 数据库> > mongodb 3.2.4 添加用户

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


标签:mongodb,db,pwd,添加,role,user,createUser,3.2,id
来源: https://www.cnblogs.com/seasonzone/p/14776681.html