Saturday, 22 May 2021

What are the different Built-in roles in MongoDB? | MongoDB Tutorial for Beginners

🚀 Enjoying this guide? Subscribe to our YouTube channel for more beginner-friendly tech tutorials!

SUBSCRIBE NOW

Mastering Built-in Roles in MongoDB

Managing a database isn't just about storing data; it's about who can access and change it. In MongoDB, we use Roles to control these permissions. Let's break down the most common built-in roles in a way that's easy to understand!

1. Database User Roles

These are the basic roles for people who just need to work with the data inside a specific database.

  • read: The user can see and search data but cannot change anything.
  • readWrite: The user can see, add, update, and delete data within the collections.

2. Database Administration Roles

These roles are for users who need to manage the structure of the database itself.

  • dbAdmin: Allows performing administrative tasks like cleaning up databases or viewing statistics.
  • userAdmin: Allows creating and managing other users and roles within that specific database.

3. Cluster Administration Roles

These are high-level roles used for managing the entire MongoDB server or "Cluster."

  • clusterAdmin: Provides the greatest power over the entire cluster, including replication and sharding tasks.
  • clusterManager: Focused on managing and monitoring the cluster's health.

4. Backup and Restore Roles

Specific roles designed to handle data safety without giving full admin access.

  • backup: Necessary permissions to use tools like mongodump to save your data.
  • restore: Permissions required to bring data back into the database using mongorestore.

Summary Tip

Always follow the Principle of Least Privilege. Only give users the exact permissions they need to do their jobs. For example, a developer might only need readWrite, while a viewer only needs read.

Check out these related tutorials:

No comments:

Post a Comment