centos mongodb 3.4 认证配置

use admin
db.createUser({user: “root”, pwd: “123456”, roles:[“root”]})
重启mongodb
mongod –auth –port 27017 –dbpath /var/lib/mongodb

mongo -u “root” -p “123456” –authenticationDatabase “admin”

use cd2
db.createUser({user: “cd2”, pwd: “cd2”, roles:[“dbOwner”]})
If you see success messsage, disconnect from mongo shell and reconnect with new user credentials.

mongo /cd2 -u “cd2” -p “cd2”

参考链接:http://blog.csdn.net/oscer2016/article/details/77587481

你可能感兴趣的:(mongodb)