HerbiShtini HerbiShtini - 1 year ago 118
Node.js Question

Set password to meteor's mongo database

I have deployed a meteor project in a stage server and 2 days ago I found out mongodb had no password. I was able to connect to mongodb with robomongo by only providing the IP(no username, no password).

I want to set a password to protect it. I have been following this documentation but I get "mongo/mongod not a command" when writing these commands in application's root directory or after "meteor mongo" command.

What am I missing here, how can I protect mongodb with a password?


Answer Source

I don't think you can, when you are running Meteors built-in MongoDB server.

The reason for this is that if you put a password on that database, Meteor will not be able to connect to it.

And to specify a password in the MongoDB connection you need to set the MONGO_URL environment variable.

And when you do that Meteor will think you are running an external MongoDB installation and it will not even start the built-in MongoDB server.

So it's kind of catch-22.

So to set a password you need to have a separate MongoDB installed on your server, set a password on that one, and then tell Meteor to use it using a MONGO_URL environment variable in the format:


See https://docs.meteor.com/api/collections.html#mongo_url

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download