title: MongoDb - Give user access to specific database
body: <p>I'm working on an application using different databases and struggling to implement the correct user management.</p>
  <p>Suppose that we have a user &quot;BasicUser&quot; (created in the admin database), that only has dbAdmin rights to a specific database, called &quot;TestDb&quot; in this example. Furthermore, we have created a user &quot;TestUser&quot; without any access rights to start from.</p>
  <p>Is there a possibility for the BasicUser to grant read/write access to the TestDb for the TestUser?</p>
  <p>I tried the following options when I login with the BasicUser</p>
  <ul>
  <li>use TestDb; db.grantRolesToUser(&quot;TestUser&quot;, [&quot;read&quot;]) --&gt; This returns an error that the user cannot be found</li>
  <li>use TestDb; db.updateUser(&quot;TestUser&quot;, {roles: [&quot;read&quot;]}) --&gt; This returns an error that we are not autorized to execute the command</li>
  </ul>
  <p>To be clear, I do not want to provide the BasicUser any admin rights on the admin database, as I don't want the BasicUser to see any of the other databases. This user should only be able to see the TestDb and perform its admin tasks on this db.</p>