Gulzaib Amjed
Gulzaib Amjed

Reputation: 3

import large JSON file into mongo

Due to some migrations and change in server, I have to change my Mongo database from old to new data is also need to transfer but data is too much now almost ~4GB of each file. In total, I have almost 20 files. My problem is when I upload to new collections it says "tostring" error. I read and come to know there is the limit from MongoDB of 16mb to import a file. How can I import JSON file into MongoDB? Thank you in advance.

Upvotes: 0

Views: 1063

Answers (1)

robjwilkins
robjwilkins

Reputation: 5652

If you read the documentation for mongoexport it says:

Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality.

Rather than using mongoexport to create a json file and then mongoimport to reimport it, you should use mongodump and mongorestore.

Upvotes: 1

Related Questions