Skip to content

Instantly share code, notes, and snippets.

@maksimKorzh
Last active April 2, 2019 17:42
Show Gist options
  • Save maksimKorzh/2a898ddda6f81afc5d800e582986fc84 to your computer and use it in GitHub Desktop.
Save maksimKorzh/2a898ddda6f81afc5d800e582986fc84 to your computer and use it in GitHub Desktop.
// Start service
sudo service mongod start
// Stop service
sudo service mongod stop
//Restart service
sudo service mongod restart
// Start client
mongo
- show dbs // list all databases
- use name // create/switch to database
- db.dropDatabase() // delete database
- show collections
db.createCollection('name')
db.name.insert({ name: 'name' })
db.usercollection.insert({ "username" : "testuser1" })
db.usercollection.find().pretty()
newstuff = [{ "username" : "testuser2" }]
db.usercollection.insert(newstuff);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment