Unable to use Mongo Export Query

I have a collector named " sample " and a database named " in " present in Mongo DB.

db.sample.find().pretty() { "_id" : "35004", "city" : "ACMAR", "pop" : 6055, "state" : "AL" } { "_id" : "35005", "city" : "ADAMSVILLE", "pop" : 10616, "state" : "AL" } { "_id" : "35006", "city" : "ADGER", "pop" : 3205, "state" : "AL" } 

I tried using the mongo export request, but I was unsuccessful, let me know where I am making the error.

I tried using below, but always made a mistake.

 mongoexport --host localhost --db at --collection "sample" --csv --out text.csv --fields city,state mongoexport --csv -o /D:/test.csv -d at -c sample -f city,state,pop 

I got the following error, please help

Sun Mar 10 00:25:44 SyntaxError: missing; before statement (shell): 1

+8
mongodb
source share
1 answer

mongoexport should be run from the shell of the operating system, not the mongo shell.

+30
source share

All Articles