1

I have a JSON file which I want to import on MongoDB. I am very new to both. Do I need to keep my JSON file to some specific folder and what should be the command.

1 Answer 1

3

mongoimport is the command to upload JSON data into Mongo collection.

Go to the folder where you have JSON file and execute the below command after changing the parameters accordingly.

mongoimport -d <databasename> -c <collectionname> < <filename>.json

Example:

mongoimport -d students -c grades < grades.json
Sign up to request clarification or add additional context in comments.

2 Comments

"Go to the folder where you have JSON file" this is the part for which I asked the question once I am running the mongo how to do this part
Open another command prompt (i.e. normal command prompt window) and run this command. In other words, you have to execute this command outside the mongo shell. Just like normal windows command. I hope you have included the mongo installation path in the windows PATH environment variable which would allow you to find "mongoimport.exe".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.