1

I'm trying to execute

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

but it does not work

Stennie
  • 63,885
  • 14
  • 149
  • 175
Decastrio
  • 133
  • 2
  • 10
  • possible duplicate of [How to export json from Mongodb using robomongo](http://stackoverflow.com/questions/28733692/how-to-export-json-from-mongodb-using-robomongo) – gpullen May 26 '15 at 09:29
  • Can you show us the error? – Dev May 26 '15 at 09:29
  • are you connected to mongod instance ? – PaulShovan May 26 '15 at 09:33
  • I just type this command and robomongo validator displays "Error: Line 1: Unexpected identifier " at once . Way? – Decastrio May 26 '15 at 09:36
  • https://yadi.sk/i/cfdWh_uyeHZWV pic – Decastrio May 26 '15 at 09:43
  • 2
    @ЮрийСадовой instead of running `mongoexport` command in robomongo try to run on mongo shell – Neo-coder May 26 '15 at 11:10
  • @yogesh I installed mongodb-win32-x86_64-2008plus-ssl-3.0.3-signed and Tried to execute this in cmd: C:\Windows\System32>cd C:\Program Files\MongoDB\Server\3.0\bin C:\Program Files\MongoDB\Server\3.0\bin>mongoexport -d Mydb -c Items229900 -o It ems229900.json 2015-05-26T15:01:16.895+0300 error opening output stream: open Items229900.js on: Access is denied. – Decastrio May 26 '15 at 12:03
  • I tried this: C:\Program Files\MongoDB\Server\3.0\bin>mongo.exe MongoDB shell version: 3.0.3 connecting to: test 2015-05-26T15:21:16.286+0300 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:10061 Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение. 2015-05-26T15:21:16.290+0300 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at connect (src/mongo/shell/mongo.js:179:14) at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed – Decastrio May 26 '15 at 12:22

3 Answers3

2

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...

Yogesh Nikam Patil
  • 1,192
  • 13
  • 18
0

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

Daniel Vukasovich
  • 1,692
  • 1
  • 18
  • 26
  • Robomongo works on Usadovoy.st.local:27000, i can create DB, collections etc but when i try to run C:\Program Files\MongoDB\Server\3.0\bin\mongo.exe i get error: MongoDB shell version: 3.0.3 connecting to: test 2015-05-26T15:21:16.286+0300 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:10061 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at connect (src/mongo/shell/mongo.js:179:14) at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed – Decastrio May 26 '15 at 12:34
  • mongo usadovoy.st:27000/test where: "usadovoy.st" is hostname, "27000" is port address and "test" is database instance name. – Daniel Vukasovich May 26 '15 at 12:39
  • There is my mongodb.org account and there is test too – Decastrio May 26 '15 at 12:42
  • are you executing this command at "usadovoy.st" server or at your local workstation ? This message "Error: couldn't connect to server 127.0.0.1:27017"indicates that you are trying to connect to a local instance . Your original question is about using "mongoexport" .. was this issue resolved ? – Daniel Vukasovich May 26 '15 at 12:42
  • Not get resolved. I cannot create connection at 127.0.0.1:27017 with robomongo, only Usadovoy.st.local:27000 – Decastrio May 26 '15 at 12:46
  • In mongodb.org: Connect to Your Deployment To connect to this Mongod via the mongo shell: C:\MMSAutomation\versions\mongodb-win32-x86_64-3.0.3\bin\mongo USadovoy.st.local:27000 //////// How to change from 127.0.0.1:27017 to USadovoy.st.local:27000 for local default connect? – Decastrio May 26 '15 at 12:56
0

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.

vmr
  • 1,895
  • 13
  • 24