Lesson 3.1 errmsg: not authorized on admin to execute command

Hey can somebody help me with this

db.currentOp()
{
“ok” : 0,
“errmsg” : “not authorized on admin to execute command { currentOp: 1.0, lsid: { id: UUID(“6867be55-995f-4eab-83ee-c403e6e6645c”) }, $db: “admin” }”,
“code” : 13,
“codeName” : “Unauthorized”
}

i have a user and Im loged in, but i cannot run db.currentOp() , why being loged in is ignored ? what is the solution ?

@artur_o which course does this relate to? Can you possibly edit your post and attach it to a course?

I have edited my post, sorry

Good man! :+1:

It looks like the user that’s logged in doesn’t have the correct access rights. Run db.getUsers() to see what the roles are for the user.

And also try to use db.auth() to authenticate as the authorised user. Finally, switch to the db you will like to run currentOp against.

So im totally confused, im running db.getusers() and I get empty array

db.auth(username, password) says that my user is not defined, it is not possible as i login like mongo -u user -p passwort -authenticationDatabase admin

What could be wrong ?

If I remember correctly, this course doesn’t use a virtual environment. And everything you run is on the localhost, i.e. no username/password required.

Show me exactly how you are login in and all the other steps you are running. Let me see a full screenshot of all of that.

Fyi, it’s db.auth("username", "password"). Quotes is necessary.

@artur_o here’s my session:
image

As you can see, I’m not authorising any user. I used the localhost for this course.

you are right this course does not require any authorization, but im retaking this course and i have already set up a user in the past. ok , i will drop user and see if it will work but i found partial solution, adding { “$ownOps”: true } works,

you are right this course does not require any authorization, but im retaking this course and i have already set up a user in the past. ok , i will drop user and see if it will work but i found partial solution, adding { “$ownOps”: true } works

Good workaround.

If you give the user the appropriate role on the m201 db and you’ll be able to run currentOp() without the $ownOps option. See here https://docs.mongodb.com/manual/tutorial/manage-users-and-roles/