Skip to content

Instantly share code, notes, and snippets.

@methodin
Created February 1, 2011 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save methodin/805996 to your computer and use it in GitHub Desktop.
Save methodin/805996 to your computer and use it in GitHub Desktop.
Useful commands/examples for Mongo
// Adding a user auth to a DB (read/write, add true as a third param for read-only)
use somedb
db.addUser("username","pasword")
// Update an entry (don't forget $set or it will be replace only with what is provided)
db.gadgets.update({key:"Some criteria"},{$set:{weight:17.6}})
// Dump a database/collection
mongodump -d databasename -c collection -o .
// Start a mongo instance with authentication required
mongod --fork --logpath /var/log/mongodb.log --logappend --auth &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment