HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Import and Export database in Mongo just like MySQL

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
justmongolikedatabasemysqlexportandimport

Problem

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.

Solution

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

Code Snippets

$ ./mongodump
$ ./mongodump --host prod.example.com
$ ./mongodump --db blog --collection posts

Context

StackExchange Database Administrators Q#15625, answer score: 3

Revisions (0)

No revisions yet.