Wednesday, 12 April 2017

How to export MongoDB database from cloud9 to mlab?

So I created a web app on cloud9 using Node.js, mongoDB, express. I set up MongoDB in cloud 9 as per the instructions.

When I completed the app, I deployed it to Heroku, and created a new db in mlab (mongolab). This works fine.

However, I inserted a lot of dummy data into the db hosted on cloud9. I want to copy this dummy data from the db in cloud9 to the db in mlab. How do i do that?


I did some research.

According to mongodb docs, I should use db.copyDatabase():

db.copydatabase(fromdb,todb,fromhost,username,password,mechanism)

It says I should run this command in the destination instance, i.e. the instance receiving the copied data.

I'm assuming this means that I should connect to the db hosted on mlab through: mongo dsblahblah.mlab.com:59220/blahblah -u -p

and then run the db.copyDatabase command, correct?

But what should I use for the fromdb parameter? This is the db that is hosted in cloud9. But what is this db's url?

Help. And ELI5.



via Asool

No comments:

Post a Comment