Articles → MONGODB → Mongoimport Utility

Mongoimport Utility






Purpose





Syntax


mongoimport --host [host] --port 27017 --db [database name] --collection [collection name] --file [json file] --jsonArray



Sample JSON




[
  {"subject": "MongoDB Basics"},
  {"subject": "Data Modeling in MongoDB"},
  {"subject": "Indexing and Query Optimization"},
  {"subject": "Aggregation Framework"},
  {"subject": "MongoDB Atlas Overview"},
  {"subject": "Replication and Sharding"}
]





Example




mongoimport --host localhost --port 27017 --db test --collection Articles --file C:/mongo/subject.json --jsonArray


Picture showing the execution of the mongoimport command



Output




Picture showing the data is imported in the collection





Posted By  -  Karan Gupta
 
Posted On  -  Friday, December 8, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250