MongoDB
Basic Commands
Start it
mongoShow databases
show dbsSelect a database
use databaseList tables (collections)
show collectionsShow content from a collection (table)
db.<collection>.find().pretty()Passing parameters (greater than/equal)
db.<collection>.find({ age: { $gte: 18 } })Limit results (first five)
db.users.find().limit(5)Dump a database
mongodump --db <database_name> --out <backup_directory>Dump a collection
mongodump --db myDatabase --collection myCollection --out /path/to/backup/
codesheMongo dump the data in binary form, creating BSON files, in order to convert then is a readable form use:
bsondump <input_bson_file>It's possible also to restore a database from a dump file with:
mongorestore --db <database_name> <path_to_backup>Last updated