数据库
首页 > 数据库> > MongoDb 创建用户

MongoDb 创建用户

作者:互联网

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"]});

 

标签:MongoDb,SCRAM,db,用户,cpeducloud2,SHA,role,创建
来源: https://www.cnblogs.com/sunxun/p/12485777.html