0

I am an issue in mongoimport for mongoDB ATLAS clusters but not able to find any solution.

I am following the below steps:

1. I have created the free account in mongodb atlas

2. I have then created a cluster

3. Then i have added in IP Whitelist

4. Then i am using normal command prompt(not mongo shell)

5. I am then using command cd and going to C:\mongodb\bin

6. Next step i am copying the code (mongo "mongodb://cluster0-shard-00-00-..........) from "Connect via the Mongo Shell"

7. I am now connected to the cluster(Cluster0-shard-0:PRIMARY>)

8. Next step i am using mongoimport command :

mongoimport --host cluster0-shard-00-00-xxxx.mongodb.net:27017 --db starwarsdb --type json --file ~c:\Users\xxxx\Downloads\starwars.json --jsonArray --authenticationDatabase admin --ssl --username --password

9. I am getting the below error:

2017-10-22T16:05:48.994-0400 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14


enter image description here I am not able to figure out the solution. Your help will be highly appreciated.

  • 1
    What you did wrong was typed the command into the "mongo shell" instead of on the command line like you are supposed to do. For some reason someone asks the same question here about once a month. Quoting the [actual documentation page](https://docs.mongodb.com/manual/reference/program/mongoimport/#synopsis) ***"Run mongoimport from the system command line, not the mongo shell."*** – Neil Lunn Oct 22 '17 at 21:18
  • I have tried that also. Sorry i forgot to mention. But it is not working to import a file onto Atlas. – Utility Expert Services Oct 22 '17 at 22:48
  • It''s not a matter of "tried that also", it's simply that the error: `QUERY [thread1] SyntaxError: missing ; before statement ` is **only** produced from running the `mongoimport` command in the wrong place. Much like the person who asked the same duplicate question, anything else is a "completely different error" with completely different reasons. Also please don't make statements such as **"facing a known issue"** without backing them up with facts. There is no "known issue" that I am aware of. There is only incorrect usage and options. – Neil Lunn Oct 23 '17 at 00:03
  • Ok thank you for your feedback. So, can you help in resolving this issue? i have explained all the steps and not able to find any solution. – Utility Expert Services Oct 23 '17 at 01:29
  • There are plenty of notes on the [marked duplicate](https://stackoverflow.com/questions/11041961/cannot-import-mongodb) where the OP posted the same error for the same cause. If you actually run from the command line and receive a "different error" then that is a "different question" for which you [Ask a new Question](https://stackoverflow.com/questions/ask) with details of the new and specific error. Anything with `QUERY` in it means you are "still" running in the wrong place, and that is the issue you need to pay attention to. Please note that "other errors" likely also have answers already – Neil Lunn Oct 23 '17 at 01:33
  • Thank You so much. Actually i checked many post but i could not find an explanation where actually the code needs to run. It became obvious that we cannot run in mongo shell for mongo import. I finally figured it out. As you advised, i payed more attention to the location and found that i was indeed running the query in different location. I finally ran the same query in location:C\mongodb\bin and the file was uploaded to the server. – Utility Expert Services Oct 23 '17 at 01:50

0 Answers0