Few Commands about How to Export/Import MongoDB Collections
2014/5/311 min read
bookmark this
Following example is export/import to your localhost's mongo database.
Export Collection from Mongo Database
Mongodb/bin>mongoexport --db {your database} --collection {your collection} --out {your file name}.json
Import Collection to Mongo Database
Mongodb/bin>mongoimport --db {your database} --collection {your collection} --file {your file name}.json
Import Collection to Mongo Database(remote)
Note: collection needs to be before --db.
Mongodb/bin>mongoimport --host {host server name} --port {server port number} --username {db username} --password {password} --collection {collection name} --db {database name} --file {your file name}.json