0

I have a MongoDB user created into admin database

When i try to use some functions (from mongoDB native driver in nodeJs) it throws an error:

{ name: 'MongoError', message: 'not authorized on stop to execute command { findandmodify: "users", query: { _id: 1 }, new: true, remove: false, upsert: true, update: {...

{
    "_id" : "admin.admin",
    "user" : "admin",
    "db" : "admin",
    "credentials" : {
        "SCRAM-SHA-1" : {
            "iterationCount" : 10000,
            "salt" : "xxxx",
            "storedKey" : "xxxx",
            "serverKey" : "xxxx"
        }
    },
    "roles" : [ 
        {
            "role" : "root",
            "db" : "admin"
        }, 
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }, 
        {
            "role" : "readWriteAnyDatabase",
            "db" : "admin"
        }, 
        {
            "role" : "dbOwner",
            "db" : "admin"
        }, 
        {
            "role" : "clusterAdmin",
            "db" : "admin"
        }
    ]
}

Any other commands like find or update works.

I want this user to be a SUPER USER but I have assigned it all type of roles, but none of them works, i tried root, adminAnyDatabase, etc.

I'm using mongodb 3.0.9

Any idea how to solve this? Which permision do i need to allow findAndModify command?

  • After some digging, i restarted my mongodb server and all started working as expected. Is there a way to "delete" this question? – Pipe Feb 18 '16 at 17:14
  • 2
    You should be able to delete it. However, you can put your solution as an answer, because it might help others. A side note: NEVER use an admin user for data access. Create a specialized user with as few privileges as possible to get the job done. – Markus W Mahlberg Feb 23 '16 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.