mongoexport E QUERY SyntaxError: Unexpected identi

2019-01-24 04:55发布

问题:

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:

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...

回答1:

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



回答2:

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