24

The issue seems straight forward. I have a database (test) and a collection called (users) so I run the command:

mongoexport -d test -c users -o output.json

However I get the below error:

E QUERY     SyntaxError: Unexpected identifier

As per what I have figured out till now over the internet, this may have something to do with the file path but I am unsure as how to amend this as I never mess with PATH variable due to a bad experience...

2
  • 3
    You don't run mongoexport from the mongo shell, you have to run it from the OS shell (same as you run mongo) Commented Apr 3, 2015 at 12:05
  • Well aren't I a clown. Thank you very much! Please copy and paste as an answer and I'll accept it. :) Commented Apr 3, 2015 at 12:06

2 Answers 2

52

You don't run mongoexport from the mongo shell, you have to run it from the OS shell (same as you run mongo)

Sign up to request clarification or add additional context in comments.

3 Comments

It's been over 3 years since you answered this question and I never thanked you. Thank you. :)
This helped me a lot.
@NiallLonergan it's been almost 3 years since you'd thanked me, and I've never responded. You're welcome 😉
4

mongoexport is not a Mongo shell command, it's an operating system command.

Just like you run mongo.exe to start the shell from OS prompt, you should run mongoexport the same way from OS prompt. Example:

c:\mongodb\bin>mongoexport --db ventfeed --collection users --out C:\temp\contacts.json

Thanks

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.