Mongoimport is used to upload the JSON or CSV file into the Mongo database, this is used as a bulk upload of data to MongoDB. using Mongoexport we can download the existing data. Json file should be well formatted, without commas as separation for each document.

Mongoimport should be used in command prompt not in the clients of MongoDB.

Syntax :

mongoimport --host hostIP --port Portnumb --username uname --password pswd --collection collname --db dbname --file filepathwithFilename

Example :

mongoimport --db MyDB --collection regdetail --file "regis.json" 

To execute the above command the file should be in the root directory of MongoDB

mongoimport --db MyDB --collection regdetail --file "D:\file1.json" 

Above command will fetch the file from the specified path.