时间:2021-07-01 10:21:17 帮助过:16人阅读
1
cd $MONGO_HOME/bin/
./mongo --shutdown --dbpath /data01/app/mongo/data
./mongo --fork --logpath /data01/app/mongo/logs/mongodb.log --dbpath /data01/app/mongo/data
./mongo 127.0.0.1:port/admin
use admin;
db.createUser({user:‘root‘,pwd:‘$PWD‘,roles:[{role:‘root‘,db:"admin"}]});
2
cd $MONGO_HOME/bin/
./mongo 127.0.0.1:port/admin
use admin;
db.auth("root","$PWD")
db.createUser({user:"lych",pwd:"lych000",roles:[{role:‘dbAdmin,db:"lych"},{role:"readwrite",db:"lych"},{role:"userAdmin",db:"lych"}]})
mongo创建新用户与数据库
标签:新建库