show dbs
TestDB 0.078GB
use TestDB
switched to db TestDB
show collections
Employee
MyCollection
db.MyCollection.find()
{ "_id" : ObjectId("55cb93c412a2139d0a6078a1"), "MyNames" : "Sanal" }
mongoexport --db TestDB --collection MyCollection --type=csv --fields MyNames --out D:\contacts.csv
2015-08-22T00:44:20.380+0530 E QUERY SyntaxError: Unexpected identifier >
From that error message it looks like you are still in the mongo shell. mongoexport
is a separate utility. You need to exit the mongo shell, the command is just exit
. Then enter your mongoexport command again on the command line.