Few Commands about Import/Export Mongo Database

2014/5/101 min read
bookmark this
Responsive image

With mongodb's mongodump & mongorestore command, you can achieve export and import data to your mongo database.

1. Export Database

Go to your local mongo bin folder. Type mongodump --db {your database name}

This command will export all your database as binary file under dump folder. When I have 200 MB, totall collection around 50,000. This command run like 2,3 second in my Windows 8 (8GB memory) PC.

 

2. Restore you database to the remote connected database

Asume your remote mongo database have nothing, you just want to import everything you just export from local mongo datatabase. Run following command.

mongorestore --db {your database} --host {server name} -- port {server port number} --username {your database user name} --password {your database user's password} dump/{your database name}