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 thenEnter 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
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 startand 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
This will import database customer to mongodb
Thanks and regards
javasimplestuff
No comments:
Post a Comment