Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-1012

error: not authorized on db to execute command

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.7
    • Component/s: mongorestore
    • Environment:
      Test

      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 (mongorestore -u testdba -p xxxxxx -d prod079 /data/backup --batchSize=1) that restored 400GB of data from the same folder, seems to fail with this one file alone.

      I'm getting an error like this :

      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 }

      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 }

      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 }

      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 : mongorestore -u admin -p xxxxx -d prod079 /data/backup --batchSize=1.

      This time I'm getting a different type of error. It says :

      2015-12-10T13:17:59.940-0500 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.

      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.

      Any suggestions/help would be greatly appreciated.

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            msampathkumar Manikandan Sampathkumar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: