I have a Mongo instance running in a docker container on an Amazon-hosted server.
I need to connect to it with either RoboMongo or MongoChef for exploration, and with command-line for automated extractions.
To get to the server from my laptop, I create an ssh tunnel:
ssh -i ~/.ssh/MY-PEM-FILE MY-USER@MY-SERVER -L 27017:localhost:27017With
MongoChef I connect as "Direct Connection" to localhost on port 27017. The connection succeeds and I see:
- Tunnel to mongo 27017 localhost:27017
- local
+ startup_log
- sg_mage
+ catalog_product_entity
- __id__I run IntelliShell and I get this in the main window:
2016-06-23T09:00:46.055-0400 I CONTROL [main] \
Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.2.4
connecting to: localhost:27017/local
2016-06-23T09:00:46.187-0400 E QUERY [thread1] \
Error: network error while attempting to run command 'whatsmyuri' on host 'localhost:27017' :
connect @ src/mongo/shell/mongo.js:226:14
@(shell):1:6 Connected: you can now execute commands from the editor above.I then run the query
db.catalog_product_entity.find({}).limit(1) but the scrollbar pumps forever, returning no results.
I can right-click the
sg_mage collection and choose
Export Collections ... and I can export the full 1.9 million items to json!
That's not really what I need ... but it demonstrates that I can "see" the data by that method.
I truly am connected, albeit with limited functionality.
Export, yes. Query, no. :(Moving to
RoboMongo ... same tunnel connection ... I see this:
- Tunnel to mongo 27017 (2)
+ System
- sg_mage
Collections (0)
Functions (0)
Users (0)No collections at all ?! But ... when I query with
db.catalog_product_entity.find({}).limit(1) I do get data:
- (1) 1 { 4 fields }
_id 1
- attr_0 { 21 fields }
entity_id 1
entity_type_id 4
attribute_set_id 4
type_id simple
etc ... etc ...
- category_ids Array [1]
0 4
- galleries { 1 fields }
media_gallery Array [0]
attr_1_url_path portugal.htmlSo I
cannot point and click through the items in the left-hand bar, but I can query the data in the main window.
This is "good enough" for investigative / ad-hoc work.
For automated extracts I want to use command-line mongo. I have that installed on my laptop (Win 7 with Cygwin bash).
I run this:
echo "use sg_mage;
db.catalog_product_entity.find({}).limit(1)" | "C:/Program Files/MongoDB/Server/3.2/bin/mongo.exe"and I get this:
MongoDB shell version: 3.2.7
connecting to: 127.0.0.1:27017/test
2016-06-23T14:16:13.100+0100 E QUERY [thread1] \
Error: network error while attempting to run command 'whatsmyuri' on host '127.0.0.1:27017' :
connect @ src/mongo/shell/mongo.js:231:14
@(connect):1:6
exception: connect failedNo joy. I really need to get this working.
Advice???