title: MongoDB shell authentication error
body: <p>I created a user and password for a database called <strong>student</strong>.:</p>
  
  <blockquote>
    <p>db.createUser({user:'Catalin',pwd:'Catalin',roles:[{role:'userAdmin',db:'student'}]});</p>
  </blockquote>
  
  <p>So I restarted MongoDB Server with this command:</p>
  
  <pre><code>mongod --auth --dbpath C:\data\db
  </code></pre>
  
  <p>in another terminal, I connected to the sever with:</p>
  
  <pre><code>mongo
  </code></pre>
  
  <p>then queried the server with :</p>
  
  <pre><code>&gt; db.getUsers()
  [
      {
              "_id" : "student.Catalin",
              "user" : "Catalin",
              "db" : "student",
              "roles" : [
                      {
                              "role" : "userAdmin",
                              "db" : "student"
                      }
              ]
      }
  </code></pre>
  
  <p>]</p>
  
  <p>went to the <strong>student</strong> database:</p>
  
  <pre><code>&gt; use student
  switched to db student
  </code></pre>
  
  <p>Entered my username and password succesfully via this command:</p>
  
  <pre><code>&gt; db.auth('Catalin','Catalin');
  1
  </code></pre>
  
  <p>and when I want to view my collections I get an error, WHY?:</p>
  
  <pre><code>&gt; show collections
  2016-03-07T15:54:41.166+0300 E QUERY    [thread1] Error: listCollections failed:
  {
      "ok" : 0,
      **"errmsg" : "not authorized on student to execute command { listCollectio
  ns: 1.0, filter: {} }",**
      "code" : 13
  } :
  _getErrorWithCode@src/mongo/shell/utils.js:23:13
  DB.prototype._getCollectionInfosCommand@src/mongo/shell/db.js:746:1
  DB.prototype.getCollectionInfos@src/mongo/shell/db.js:758:15
  DB.prototype.getCollectionNames@src/mongo/shell/db.js:769:12
  shellHelper.show@src/mongo/shell/utils.js:695:9
  shellHelper@src/mongo/shell/utils.js:594:15
  @(shellhelp2):1:1
  </code></pre>
  
  <p><strong>"errmsg" : "not authorized on student to execute command { listCollectio
      ns: 1.0, filter: {} }",</strong></p>
  
  <p>P.S. : I'm using mongoDB 3.2</p>