11

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!

Akrion
  • 18,117
  • 1
  • 34
  • 54
wicccked
  • 352
  • 1
  • 4
  • 15

6 Answers6

22

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

barrypicker
  • 9,740
  • 11
  • 65
  • 79
  • 6
    this saved me the day! – ace Jan 05 '19 at 10:36
  • I had 2 versions of compass at the same time, the old version was having this problem. OLD ==> `"C:\Program Files\MongoDB Compass\MongoDBCompass.exe" NEW ==> C:\Users\xxx\AppData\Local\MongoDBCompass\MongoDBCompass.exe New version worked fine. This happend because I installed new version of mongo without uninstalling the old Mongo and Compass – kiranvj Jun 14 '22 at 05:32
8

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.

  • Also try by killing the MongoDBCompassCommunity.exe from processes and then restart your compass again and try login with credentials. – Abhishek_Itachi Sep 17 '18 at 10:32
  • The first option worked! (I didn't try the second one) Thank you so much! I already gave up hope to have it resolved =) – wicccked Sep 17 '18 at 12:03
  • 2
    Restarting MongoDB Compass solved the issue for me. Just updating the MongoDB access rights correctly was not enough, but Compass restart was needed. –  Oct 28 '18 at 10:10
  • be careful with username/password upper/lower case sensitivity – minhhungit Jul 28 '22 at 08:27
1

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

Virender Jain
  • 91
  • 1
  • 1
1

To provide access to mongoDB via compass for minimal permissions on read/write operations, attach the role "clustermonitor" to the user as this is required for loading the initial/home screen which queries status of all databases.

Raj
  • 370
  • 4
  • 6
1

Step-1: Go to advanced connection options on your compass.

Step-2: Add username and password that you created while installation and authentication database name. (See https://techviewleo.com/install-mongodb-on-ubuntu-linux/)

Step-3: Click on connect.

0

Disconnect your GUI i.e. MongoDB Compass and restart and provide the User name and Password that you mention while installing MongoDB. Go to the Advanced Connection Options > Authentication Then provide the User name and password. Done. You can refer to this link:

https://techviewleo.com/install-mongodb-on-ubuntu-linux/?expand_article=1
Y. Joy Ch. Singha
  • 3,056
  • 24
  • 26