Decastrio
Decastrio

Reputation: 133

MongoDB, how to export json with mongoexport

I'm trying to execute

mongoexport --db Mydb --collection Items229900 --out D:/test.json

but it does not work

Upvotes: 1

Views: 8149

Answers (3)

Yogesh Nikam Patil
Yogesh Nikam Patil

Reputation: 1280

Don't run this command on the shell, enter this script at a command prompt with your database name, collection name, and file name, all replacing the placeholders.

mongoexport --db (Database name) --collection (Collection Name) --out (File name).json

it works for me...

Upvotes: 2

vmr
vmr

Reputation: 1935

Currently RoboMongo does not have this functionality of doing import/export of JSON data.

The shell that you have in RoboMongo is a 'mongo' shell, hence you cannot run utilities(like mongoimport, mongodump etc) from it. You can only run queries that are allowed in 'mongo' shell.

You can run this from command prompt in mongodb/bin : mongoexport example

There are other tools like MongoChef which support this functionality.

Upvotes: 0

Daniel Vukasovich
Daniel Vukasovich

Reputation: 1742

The command is OK, just change destination path. Change "D:/test.json" to "D:\test.json".

mongoexport --db Mydb --collection Items229900 --out D:\test.json

Or just get rid of "D:\"

mongoexport --db Mydb --collection Items229900 --out test.json

Upvotes: 0

Related Questions