How does Meteor connect to Mongo?

Very new to Meteor.

I am trying to make a separate worker process that uses the ddp and ddp-login packages to log in to my main Meteor app’s Mongo collections over DDP.

It is prompting for credentials.

My questions are:

What are the default credentials Meteor sets up to connect to Mongo?
Where are these located in the Meteor project? Where is the connection string?
How do I change these credentials?

I have been hunting all over my project source and it’s still “magical” to me.

Whell, that’s because it actually is ‘magical’ :sunglasses:

Meteor comes with its own, build-in version of Mongo
When you don’t specify a mongo-url yourself when starting meteor, meteor will start a private mongo-server, just for itself.

First start meteor with the meteor in one terminal window/tab. Then, when it’s running, start a second terminal window
You can access mongo from the command line with meteor mongo , this gives you the mongo-shell.

( It should be running on 127.0.0.1:3001/meteor )

To answer the last part of your question, to connect to a MongoDB other than the builtin one that doesn’t require credentials, set the MONGO_URL and MONGO_OPLOG_URL environment variables to a standard MongoDB connect string that tells it where to look, and you can include credentials and other things there.

2 Likes

To further clarify, you can add a username/password to the front of the Mongo connect string by separating those values with semicolons, like this:

username:password@hostname:port/dbname

See this thread on StackOverflow: