title: Creating first user in MongoDB 3.2.
body: <p>I newly installed MongoDB 3.2 and tried to create the first user which throws the following error.</p>
  
  <p>" Error: couldn't add user: not authorized on admin to execute command"</p>
  
  <p>I followed mongoDB 3.2 documentation,
  <a href="https://docs.mongodb.org/manual/tutorial/enable-authentication/" rel="nofollow noreferrer">https://docs.mongodb.org/manual/tutorial/enable-authentication/</a></p>
  
  <p>To add the administrator, I tried the following code which results in the above error</p>
  
  <p>Create the user administrator.
  Add a user with the userAdminAnyDatabase role. For example, the following creates the user myUserAdmin on the admin database:</p>
  
  <pre><code>use admin
  db.createUser(
    {
      user: "myUserAdmin",
      pwd: "MY_PASSWORD",
      roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
    }
  )
  </code></pre>
  
  <p>I gone through the other stackoverflow answers as well like but with no luck,</p>
  
  <p><a href="https://stackoverflow.com/questions/23943651/mongodb-admin-user-not-authorized">MongoDB - admin user not authorized</a></p>
  
  <p><a href="https://stackoverflow.com/questions/30324901/update-role-user-not-authorized-on-admin-to-execute-command">Update role user: not authorized on admin to execute command</a></p>
  
  <p>My full error,</p>
  
  <pre><code> E QUERY    [thread1] Error: couldn't add user: not authorized on admin to execute command { createUser: "myUserAdmin
  ", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 30000.0
  } } :
  _getErrorWithCode@src/mongo/shell/utils.js:23:13
  DB.prototype.createUser@src/mongo/shell/db.js:1225:11
  @(shell):1:1
  </code></pre>
  
  <p>Thank you</p>