title: error: not authorized on db to execute command
body: <p>I'm trying to restore  a huge file using mongorestore in mongo 3.0.7. All the files under the folder prod079 has been restored successfully except for one called system.users. The command used to restore is</p>
  
  <pre><code> mongorestore -u testdba -p xxxxxx -d prod079 /data/backup --batchSize=1
  </code></pre>
  
  <p>The above command restored 400GB of data from the same folder, but seems to fail with this one file alone. </p>
  
  <p>I'm getting an error like this :</p>
  
  <blockquote>
    <p>error: not authorized on prod079 to execute command { insert:
    "system.users", documents: [ { _id: ObjectId('531e5251864fb4e84b'),
    pwd: "xxxxxxxx", roles: [ "dbAdmin", "readWrite", "userAdmin" ], user:
    "ab" } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }</p>
    
    <p>2015-12-10T13:20:49.196-0500  error: not authorized on prod079 to
    execute command { insert: "system.users", documents: [ { _id:
    ObjectId('531e5251864fb4e84c'), user: "abuser", pwd: "xxxxxxxx",
    roles: [ "read" ] } ], writeConcern: { getLastError: 1, w: 1 },
    ordered: false }</p>
    
    <p>2015-12-10T13:20:49.196-0500  error: not authorized on prod079 to
    execute command { insert: "system.users", documents: [ { _id:
    ObjectId('5452840f169afa3a2'), user: "asmeta", pwd: "xxxxxxxx", roles:
    [ "read" ] } ], writeConcern: { getLastError: 1, w: 1 }, ordered:
    false }</p>
  </blockquote>
  
  <p>So basically I get a whole lot of errors like this. I tried looking for similar errors on stackoverflow and google but all I could find was include -d or include localhost. Then I found a post which said I didn't give userAdmin/userAdminAnyDatabase privileges for the testdba user. This time I tried running as the admin user which had the userAdmin/userAdminAnyDatabase privilege. The command I used is :</p>
  
  <pre><code>mongorestore -u admin -p xxxxx -d prod079 /data/backup --batchSize=1 
  </code></pre>
  
  <p>This time I'm getting a different type of error. It says :</p>
  
  <blockquote>
    <p>2015-12-10T13:17:59.940-0500  Failed: error connecting to db server:
    server returned error on SASL authentication step: Authentication
    failed.</p>
  </blockquote>
  
  <p>Now I'm really confused as to what is happening and why I'm facing an issue with this file alone. Also, I'm unable to understand why I'm getting an error so different, when I'm trying to restore as the admin. </p>
  
  <p>Any suggestions/help would be greatly appreciated. </p>