-1

I am trying to export mongodb collection with:

mongoexport -d InventoryPLC -c Spectra -o spectra.json;

but it is giving me error:

Syntax missing ; before statement

I search on mongodb website and other reference websites:

mongoexport -d InventoryPLC -c Spectra;

I want to export collection.

I checked stackoverflow examples and mongodb documentation:

mongoexport -d InventoryPLC -c Spectra -o spectra.json;

I want exported collection, but have had no luck.

Appreciate the help.

allenski
  • 1,652
  • 4
  • 23
  • 39

1 Answers1

1

You are probably trying to run mongoexport from inside the Mongo shell. That command must be executed outside it, from your OS command shell.

Caconde
  • 4,177
  • 7
  • 35
  • 32
  • How mongo will know which database and collection they have to connect? – isha thakur Aug 21 '19 at 17:57
  • By the parameters you are already passing in the command you posted. `mongoexport -d InventoryPLC -c Spectra -o spectra.json;`. `-d` is the database, `-c` is the collection and `-o` is the output file; – Caconde Aug 21 '19 at 18:02
  • When I am trying to connect directly, it is giving this error:Failed: Failed to parse: { find: "Spectra", filter: {}, sort: {}, skip: 0, snapshot: true, $readPreference: { mode: "secondaryPreferred" }, $db: "InventoryPLC" }. Unrecognized field 'snapshot'. – isha thakur Aug 21 '19 at 18:07
  • Add the parameter `--forceTableScan`, this way: `mongoexport --forceTableScan -d InventoryPLC -c Spectra -o spectra.json` – Caconde Aug 21 '19 at 18:13