2
votes

I made a mongoexport of some local data that I now want to mongoimport into production. I'm trying the following command:

mongoimport -h production-db-b2.meteor.io --port 27017 --username client --password password_that_expires_fast --collection collection_name --db prod_meteor_com --file ./mongo_import.json

This appears to be quite similar to the solution posted here: how to mongoimport data to deployed meteor app?

However, it's not working with the error couldn't connect to [production-db-b2.meteor.io:27017] couldn't connect to server production-db-b2.meteor.io:27017

How do I get around this?

(Note: I also tried concatenating the port and host into -h production-db-b2.meteor.io:27017 to no avail)

2
I ran into this exact issue and was planning to write a short blog post about how I get around it because it was a huge pain in the rear, I'll try to get an answer for you up soon. I know I used mongodump and mongorestore instead of import/export for one, but that's not your only problem.Spencer
try this: mongoimport -u client -h production-db-b2.meteor.io:27017 -d myapp_meteor_com -p passwordthatexpiresreallyfast /pathtofileSpencer
Hey that worked. Thanks Spencer. You want to post it below and I'll give you credit?user592419

2 Answers

1
votes

This is what worked for me in the past. I'm not exactly sure of why it works and your solution doesn't, but I think it has something to do with not specifying the collection or the file in a certain way.

mongoimport -u client -h production-db-b2.meteor.io:27017 -d myapp_meteor_com -p passwordthatexpiresreallyfast /pathtofile 
1
votes

check your port. the local meteor mongodb uses 3001 not 27017...

i'm using the following line successfully

mongoimport --host localhost:3001 -d meteor -c TestCollection --type csv --file /home/ubuntu/meteorMongoImportTest/results1.txt --headerline