Tuesday, October 21, 2014

Mongodb Import and Export database -MONGODB

 Mongodb Import and Export database -MONGODB

This post is regarding how to import and export mongodb data dump. 
To export the database we need to run  mongodump.exe.
To import the database dump we need to run mongorestore.exe.
Consider and example Customer database need to be exported and imported


WINDOWS: 

     Export Dump:
           step 1: Make sure that mongodb is running in your machine if its not running
                      go to mongodb\bin folder in your mongodb installation and run mongod.exe file 
          step 2: Run mongodump.exe file which will export all schema present in db to data folder
                     inside  bin directory of mongodb installation
          Step 3: If you want to export a particular schema of your db to a desired location in your machine
                     then press windows+r  type cmd and then Enter button your command prompt will be                          opened Go to mongo installation bin directory 
          Command : mongodump.exe -d customer --out C:\

          This will export database customer to C:\ in your machine
    Restore Dump:
         command: mongorestore.exe -d customer C:\\customer
            This will import database customer to mongodb

UBUNTU :
      Export Dump:
           step 1: Make sure that mongodb is running in your machine if its not running
                      run command sudo service mongodb start and the run the below command to 
                      export the dump
    
          Command : mongodump -d customer --out /home

        This will export database customer to /home in your machine
    Restore Dump:
         command: mongorestore -d customer /home/customer
         This will import database customer to mongodb

2 comments:

  1. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. ds4windows website

    ReplyDelete