4

I am newbie to the Mongo.Before this I have worked only with MySQL.In MySQL we can import and export database easily.I want to know is there any option available in Mongo to import and export database easily.Any help and suggestions will be highly appreciable.

asked Mar 27, 2012 at 6:08

2 Answers 2

3

If you look inside mongodb/bin folder (ls -l) You can find a couple of binaries.

The mongoDB has import and export tools.

If you're running mongod locally on the default port, you can just do:

$ ./mongodump

Example: Dumping Everything

$ ./mongodump --host prod.example.com

Example: Dumping a Single Collection

$ ./mongodump --db blog --collection posts

Others like

mongoexport, mongoimport, mongorestore, bsondump etc.

for more http://www.mongodb.org/display/DOCS/Import+Export+Tools

answered Mar 27, 2012 at 9:10
0

You can use something like this to export:

mongodump -h yourhost -d yourdbname

And to import, just run:

mongorestore

It is important to remember that mongorestore just insert new documents, but does not update or delete the old ones. If you want to discard your database, you need to use the --drop:

mongorestore --drop

This is how I export and import databases like MySQL.

You can learn more about mongodump and mongorestore here:

mongodump documentation

mongorestore documentation

answered Feb 7, 2013 at 13:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.