MongoDB Suggests that the easy way to handle security is to run it in a trusted environment, given that, "in such a configuration, one must be sure only trusted machines can access database TCP ports."
What would be the best approach for doing this? Is there a way for mongodb to natively only listen to localhost?
I'm using ubuntu 10.10
To connect to your local MongoDB, you set Hostname to localhost and Port to 27017 . These values are the default for all local MongoDB connections (unless you changed them). Press connect, and you should see the databases in your local MongoDB.
The localhost exception allows you to enable access control and then create the first user or role in the system. After you enable access control, connect to the localhost interface and create the first user in the admin database. If you create a user first, the user must have privileges to create other users.
connect('mongodb://localhost:27017/myapp'); This is the minimum needed to connect the myapp database running locally on the default port (27017). If connecting fails on your machine, try using 127.0. 0.1 instead of localhost .
Installing the MongoDB Community Server Edition allows us to host MongoDB databases locally unlike Atlas which is a cloud hosted database option.
Add the following line into mongodb.conf
:
bind_ip = 127.0.0.1
As @Josh Rickard stated in comments: don't forget to restart the process after updating the config file:
service mongodb restart
As Andreas mentioned in a round-about way:
mongod --bind_ip 127.0.0.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With