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"}]})
原文:http://2012ivan.blog.51cto.com/5241776/1976462