mongodbmongoimportmongoexport

Can I use mongdb data in my v4.4.5 database that was exported from v3.6.3?


I have a mongodb database with version 3.6.3. I have another mongodb database (on another machine) using version 4.4.5 with no documents in it. I want to put the data from the v3.6.3 into the v4.4.5 database. Can I safetly do this using mongoexport and then mongoimport or do I need to perform more steps?


Solution

  • Yes, mongoexport writes the documents out to a JSON file, and mongoimport can read that file and insert the documents to the new database.

    These will transfer only the documents, but not index information. You many want to consider mongodump/mongorestore if you also need to move indexes.