Mongo - RamonPradoMoreno/learned-at-work GitHub Wiki

Useful commands

  1. Kill server:
    mongo admin --eval "db.shutdownServer()"
    
  2. Create db:
    use hola
    
  3. Add document to db:
    db.movie.insert({"name":"tutorials point"})
    
  4. Dump all databases, with users and in only one file:
    mongodump --gzip --archive=/tmp/shared/dump.gz
    
  5. Restore all databases from previous dump:
    mongorestore --gzip --archive=/tmp/dump.gz