<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  User-Defined Roles on Self-Managed Deployments
  <a class="headerlink leafygreen-ui-1kepx47" href="#user-defined-roles-on-self-managed-deployments" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="user-defined-roles-on-self-managed-deployments">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#role-management-interface" target="_self">
     <span>
      Role Management Interface
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#scope" target="_self">
     <span>
      Scope
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#centralized-role-data" target="_self">
     <span>
      Centralized Role Data
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  MongoDB provides a number of
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/built-in-roles/">
   built-in roles
  </a>
  . However, if these roles cannot describe the
desired set of privileges, you can create new roles.
 </p>
 <div class="leafygreen-ui-15mdk4" role="note">
  <h2 class="leafygreen-ui-6n7b7d">
   Note
  </h2>
  <div class="leafygreen-ui-9mycqc">
   <p class="leafygreen-ui-1kp3ins">
    You can configure custom database roles in the UI for deployments
hosted in MongoDB Atlas. To learn more, see
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/security-add-mongodb-roles/" target="_self">
     <span>
      Configure Custom Database Roles
      <!-- -->
      .
     </span>
    </a>
   </p>
  </div>
 </div>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Role Management Interface
   <a class="headerlink leafygreen-ui-1kepx47" href="#role-management-interface" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="role-management-interface">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   To add a role, MongoDB provides the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.createRole/#mongodb-method-db.createRole">
    <code class="leafygreen-ui-1l06pbn">
     db.createRole()
    </code>
   </a>
   method.
MongoDB also provides methods to update existing user-defined roles. For
a full list of role management methods, see
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/#std-label-role-management-methods">
    Role Management
    <!-- -->
    .
   </a>
  </p>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Scope
   <a class="headerlink leafygreen-ui-1kepx47" href="#scope" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="scope">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   When adding a role, you create the role in a specific database. MongoDB
uses the combination of the database and the role name to uniquely
define a role.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   Except for roles created in the
   <code class="leafygreen-ui-1l06pbn">
    admin
   </code>
   database, a role can only
include privileges that apply to its database and can only inherit from
other roles in its database.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   A role created in the
   <code class="leafygreen-ui-1l06pbn">
    admin
   </code>
   database can include privileges that
apply to the
   <code class="leafygreen-ui-1l06pbn">
    admin
   </code>
   database, other databases or to the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/resource-document/#std-label-resource-cluster">
    cluster
   </a>
   resource, and can inherit from roles
in other databases as well as the
   <code class="leafygreen-ui-1l06pbn">
    admin
   </code>
   database.
  </p>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Centralized Role Data
   <a class="headerlink leafygreen-ui-1kepx47" href="#centralized-role-data" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="centralized-role-data">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   MongoDB stores all role information in the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/system-roles-collection/">
    system.roles
   </a>
   collection in the
   <code class="leafygreen-ui-1l06pbn">
    admin
   </code>
   database
  </p>
  <p class="leafygreen-ui-1kp3ins">
   Do not access this collection directly but instead use the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/#std-label-role-management-commands">
    role
management commands
   </a>
   to view and edit custom roles.
  </p>
 </section>
</section>
