How to import and export the data from MongoDB in json format?
You can use these query to import and export the data from MongoDB in JSON format.
First of all you need to install MongoDB in your system.
Then open cmd with administrator
Now go to mongodb bin directory like
C:\wamp\bin\mongodb\mongodb-win32-x86_64-2008plus-2.4.12\bin
Then run this command
Query to Export
mongoexport --db databasename --collection collectionname --out filename.json
Now you need to import the data from your file which you have backup recently
Query to Import
mongoimport --collection collectionname --db databasename --file filename.json
By use these query you can import and export the data from mongoDB in json format
Now if you have to use these query then use same process to import and export
Then open cmd with administrator
and then run these command with your mongoDB details
Query to import
mongoimport --host hostname --port 27017 --username yourusername --password yourpassword --collection collname --db dbname --file filename.json
Update the collection via import
You can also update the data from same export file just open and make changes in json file and import
To more info please check second mongoDB blog
here you can find how can you update the collection on the basis of _ID
Click here to check the import function to update collection
First of all you need to install MongoDB in your system.
Then open cmd with administrator
Now go to mongodb bin directory like
C:\wamp\bin\mongodb\mongodb-win32-x86_64-2008plus-2.4.12\bin
Then run this command
Query to Export
mongoexport --db databasename --collection collectionname --out filename.json
Now you need to import the data from your file which you have backup recently
Query to Import
mongoimport --collection collectionname --db databasename --file filename.json
By use these query you can import and export the data from mongoDB in json format
Now if you have to use these query then use same process to import and export
Then open cmd with administrator
and then run these command with your mongoDB details
Query to import
mongoimport --host hostname --port 27017 --username yourusername --password yourpassword --collection collname --db dbname --file filename.json
Update the collection via import
You can also update the data from same export file just open and make changes in json file and import
To more info please check second mongoDB blog
here you can find how can you update the collection on the basis of _ID
Click here to check the import function to update collection
Comments
Post a Comment