Share single database between multiple local Meteor apps

Hi,

Is there a way to connect to a database from another local Meteor app? I’d like to use the same database for two different apps running locally, but I’m not sure how to do this. What should be set for MONGO_URL?

Dump and restore your database on a cloud provider like mongolab

Use mongodump on your local database to get a snapshot of your database.

Set up a sandbox database on https://mongolab.com/

restore your database

You will find the MONGO_URL in their database interface

Before you startup meteor export the MONGO_URL variable

Will look something like this
export MONGO_URL=mongodb://username:password@x.mongolab.com:port/yourdatabase

Then start meteor and you are good to go

when starting the other meteor app export the same URL and voila 2 local apps 1 cloud database

Thanks

I worked out a way to do it all locally.

I started the original meteor app on port 3005. This runs mongodb on port 3006.

I then ran the following for new app and the database is now shared:
export MONGO_URL=mongodb://localhost:3006/meteor
meteor

5 Likes

I have used the same method but no database is shared between 2 apps. Is their any other method?

This method should work. Can you connect to your database using a mongo
client such as robo mongo?

Make sure mongodb really is running on port 3006. And make sure the mongo
url is exported correctly.

I have checked it like more than 10 times but it wasn’t running. I have asked my question in one of the forums here. Could you please answer me in a brief manner over their?

This topic is dedicated to the same question. I would recommend first working out how to connect to the Mongo database from a mongo client. Once you’ve successfully done that you can play with getting another Meteor instance connected to it.