Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create your superuser
- $ mongo
- > use admin
- > db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
- > exit
- # Alias for convenience (optional and at your own risk)
- $ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
- $ source ~/.bash_profile
- # Add user to your DB
- $ mongo
- > use some_db
- > db.createUser(
- {
- user: "mongouser",
- pwd: "someothersecret",
- roles: ["readWrite"]
- }
- )
- # If you get locked out, start over
- sudo service mongod stop
- sudo mv /data/admin.* . # for backup
- sudo service mongod start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement