Couldn't add user: not authorized on admin to execute

Not able to execute createUser() command in mongo. Showing error
“couldn’t add user: not authorized on admin to execute”…need help

Hi @Rohan_82787,

Check if you have already create this user. Try authenticating with the user using:

MongoDB Enterprise >  use admin
MongoDB Enterprise > db.auth("m103-admin","m103-pass")

If it outputs 1, means the user is already there.

If it shows 0 and you are unable to create the user m103-admin , then stop mongod and run mongod without authentication. Comment the authentication line in config file if you are using configuration file.

Let me know if it helps!

Curriculum Support Engineer

1 Like