0
mongoimport --db test --collection collection1 --file c:/test.json

I got SyntaxError: Unexpected identifier when executing the above command.

What is the problem of this script?

Thank you very much

1

2 Answers 2

4

I had the same issue when i tried to import json file from MongoDB Shell.
You can query it from command prompt.
My directory stucture:

C:\Program files\MongoDB\Server\3.0\bin\mongoimport.exe  
C:\filename.json

e.g.

C:\Program Files\MongoDB\Server\3.0\bin> ./mongoimport --db dbname --collection collection_name C:\filename.json  

Output should be:

2015-08-18T09:34:25.617-0700    connected to: localhost
2015-08-18T09:34:25.632-0700    imported 10 documents

Now switch back to MongoDB Shell:

 C:\Program Files\MongoDB\Server\3.0\bin> ./mongo
 use dbname
 db.collection_name.find().pretty()
Sign up to request clarification or add additional context in comments.

Comments

0

One problem here could be that you do not have your PATH set properly on your computer. If you are using Windows 10 -

  • go to Control Panel and to System Security System
  • then find the Advanced System Settings on the left panel.
  • A window will pop up - at the bottom will be a button for Environment Variables
  • Click that and the new window will have two panels of Variables
  • find and select Path in both user / system panels - click edit and add a new path with the path to the MongoDb exe
  • example : C:\Program Files\MongoDB\Server\3.6\bin

Comments

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.