Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoexport E QUERY SyntaxError: Unexpected identifier

Tags:

export

mongodb

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

like image 317
Niall Lonergan Avatar asked Apr 03 '15 11:04

Niall Lonergan


2 Answers

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

like image 140
Ori Dar Avatar answered Oct 29 '22 02:10

Ori Dar


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

like image 45
Dineshaws Avatar answered Oct 29 '22 03:10

Dineshaws