Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting using MongoDB Compass

I'm trying to see the contents of a collection using MongoDB Compass. I have username/password authentication set up. I can log in successfully but can't see any documents in the collection. Instead, I see the error:

An error occurred while loading navigation: command hostInfo requires authentication.

Here are the list of roles the user has:

"roles": [{
    "role": "readWrite",
    "db": "moviesDB"
  },
  {
    "role": "dbAdmin",
    "db": "moviesDB"
  },
  {
    "role": "dbOwner",
    "db": "moviesDB"
  },
  {
    "role": "clusterMonitor",
    "db": "admin"
  },
  {
    "role": "dbAdmin",
    "db": "moviesDB"
  }
]

I can successfully query the collection using mongo shell and node.js driver but not through Compass. If someone could tell me what I'm doing wrong I'd appreciate it. Thanks in advance!

like image 273
wicccked Avatar asked Aug 17 '18 19:08

wicccked


3 Answers

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.

like image 85
Abhishek_Itachi Avatar answered Nov 16 '22 11:11

Abhishek_Itachi


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

like image 27
barrypicker Avatar answered Nov 16 '22 11:11

barrypicker


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

like image 1
Virender Jain Avatar answered Nov 16 '22 10:11

Virender Jain