TylerBrock / mongo-hacker

MongoDB Shell Enhancements for Hackers
tylerbrock.github.io/mongo-hacker
MIT License
1.79k stars 235 forks source link

not authorized on mydb to execute command { profile: -1.0 } when doing simple find() #140

Closed mateodelnorte closed 9 years ago

mateodelnorte commented 9 years ago

The following command

mydb:PRIMARY> db.notifications.find({ 'recipients._id': 'imyid' })

gets the following error

Error: profile command failed: {
  "ok": 0,
  "errmsg": "not authorized on mydb to execute command { profile: -1.0 }",
  "code": 13
}

while doing find() calls against other collections works perfectly fine.

gianpaj commented 9 years ago

that's because the user you authenticated with cannot run the profile command: http://docs.mongodb.org/manual/reference/command/profile/

mongo-hacker uses that command to know how long that query took, if used an index, etc.

You can either:

mateodelnorte commented 9 years ago

Git it. Thx.

spadejac commented 6 years ago

I just encountered this issue and got here from Google. My admin is away and cannot be bothered to add the profile action to my role.

@gianpaj https://github.com/TylerBrock/mongo-hacker/blob/master/config.js#L14 is actually index_paranoia: false, // querytime explain

According to https://tylerbrock.github.io/mongo-hacker/ if the above is set to true, then index usage will be printed on every query. Is that what really needs to be tweaked in order to get rid of:

Error: profile command failed: {
  "ok": 0,
  "errmsg": "not authorized on mydb to execute command { profile: -1.0 }",
  "code": 13,
  "codeName": "Unauthorized"
}

Thanks