Connecting using MongoDB Compass

I too got stucked in the same problem. It helped me out:-

Way 1:- cmd-1:

use admin
db.createUser({
user: "newUsername",
pwd: "password",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
})

cmd-2:

db.grantRolesToUser('newUsername',[{ role: "root", db: "admin" }])

Way 2:- Try by killing the MongoDBCompassCommunity.exe from processes and then restart your compass again and try login with credentials.

Let me know if this also helps you out.


https://docs.mongodb.com/compass/current/connect/required-access/

I gave readWriteAnydatabass and clustermonitor then it worked

Check above article to review permissions required for MongoCompass


Kill the mongodb compass processes running, and re-launch compass.