mongo
rs.remove("host-name:27017")
use admin db.createUser({user:"root", pwd:"MySecurePassword", roles:[{role:"root",db:"admin"}]})
db.createUser({user:"MyUserName", pwd:"MySecurePassword", roles:[ {role:"readWrite",db:"MyDatabase1"}, . . . {role:"readWrite",db:"MyDatabaseN"} ]})
db.shutdownServer({force:true}) exit
openssl rand -base64 755 > /mongo/keys/mongod-auth.key
service mongod stop
/etc/mongod.conf
security:
authorization: enabled keyFile: /mongo/keys/mongod-auth.key
cat /etc/mongod.conf | grep "authorization"
mongod-auth.key
/mongo/keys/mongod-auth.key
chown mongod:mongod /mongo/keys/mongod-auth.key chmod 400 /mongo/keys/mongod-auth.key cat /mongo/keys/mongod-auth.key
root
mongo -u root admin -p
rs.add("host-name:27017")
service mongod start
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.