Skip to content

Instantly share code, notes, and snippets.

@ps
Last active September 3, 2015 21:56
Show Gist options
  • Save ps/25f50a34c04e95c0a278 to your computer and use it in GitHub Desktop.
Save ps/25f50a34c04e95c0a278 to your computer and use it in GitHub Desktop.
Authenticating Mongo
1. mongo
2. use <your-database-name-here>
3. db.addUser('pawel','test')
4. exit
5. vim /etc/mongodb.conf uncomment the line '#auth=true'
6. sudo service mongodb stop
7. sudo service mongodb start
7.5 Run your application as it is now and verify that it fails since it is missing authentication.
8. in your python code add: db.authenticate('pawel','test')
9. sudo service apache2 restart
10. SHOULD BE DONE!
Note: In order to add another user and you forgot admin password undo line 5, add user, and repeat these steps.
Useful references:
http://stackoverflow.com/questions/4881208/how-to-put-username-password-in-mongodb
http://docs.mongodb.org/manual/tutorial/enable-authentication-without-bypass/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment