MongoDB Security - Are User Roles Required?


I have a droplet with my MongoDB.

On reading some security tutorials I see mention of enabling auth auth = true however I’m unsure whether I need this?

I SSH into my droplet with a sudo account. The operations I need to perform on the DB can be either read or update/insert. So is there any need to use a create another user with high enough credentials to do this? Just feels like I’m duplicating another user.

Also to add my MongoDB droplet only talks to my node droplet which in turn is open to the world (web app).

Any advice appreciated.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


Ideally, you want to isolate access and only provide just enough access to a specific user to do the job or task it needs to do.

In a way, it’s similar to MySQL/MariaDB/Percona – you wouldn’t run commands as the root user, you would create an individual user and grant user access to a specific database, thus limiting what that one user is capable of accessing. If that one user tried to access another database, it wouldn’t be able to do so unless it was granted direct access later on by either the root user or a user with the ability to grant such permissions.

When it comes to databases, given they are often the central point of storage for many applications, I would up the security when and where possible. It may very well add a little to the workload initially, but when something does happen, it makes damage control far easier and less time-consuming.

That being said, as an added layer, I’d make sure you’re backing up your database & data often so that, in the event something does happen, you can quickly restore.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel