I have a collecton named \"sample\" and database named \"at\" present in Mongo DB .
db.sample.find().pretty()
{
\"
mongoexport
must be run from your OS command shell, not the mongo shell.
Or if that doesn't work try this approach.
If there is NO db
or data
folders in \bin
folder, create them.
Then open a new terminal and run:
for example - "C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe"
Leave this terminal open and minimize it.
Now open another terminal and run:
for example -"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe"
Leave open and minimize as well. Now open one more terminal and navigate to your
mongodb folder: for example "C:\Program Files\MongoDB\Server\4.0\bin"
Once in the correct filepath run whatever mongo commands you want but instead of
mongoexport
try this ./mongoexport
Hopefully, this may help someone.
You should be able to run a command like:
./mongoexport -h YOUR.mlab.com:PORT -d YOUR-DB-NAME -c <collection> -u <user> -p <password> -o <output file>
Or for the entire DB use:
./mongodump -h YOUR.mlab.com:PORT -d YOUR-DB-NAME -u ADMIN-USER -p PASSWORD -o C:\Luke\I\Am\Your\Father\DestinationOfAllCollections