mogodb 设置用户名密码认证:

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
#step 1: create account
1. mongo; 
2. use admin; 
3. db.createUser({ user: "root", pwd: "root", roles: [{ role: "userAdminAnyDatabase", db: "admin" }] }); 
4. db.auth("root", "root");

#step2: set authenticate
/etc/mongod.conf 
auth = true  (uncomment it if it's comment)


#step3: restart again
sudo service mongod restart

#step4. check connect :
mongo --port 27017 -u"root" --authenticationDatabase "admin" -p"root"

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄