Unable to connect to mongodb using compass

Hello There,

I have followed the instructions of Lecture: Connecting to MongoDB Using Compass. I am unable to connect with compass.

I tried with mongo shell which throws authentication failed.

Attached the screenshot FYR.

Thanks,
Raghavendra

What connect string you used for Compass?

For shell try this

mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

or try SRV string

mongo “mongodb+srv://cluster0-jxeqq.mongodb.net/test” -u m001-student -p m001-mongodb-basics

1 Like

I was able to connect. My issue was after my Mac OS upgrade, the files got moved to:
/Users/Shared/Previously Relocated Items/Security/data/db

I was cleaning up my laptop and deleted that dir thinking I didn’t need it. I upgraded mongo using brew and reinstalled Mongo Compass, to no avail.

In the end, what I did was:

  1. brew upgrade mongosh
  2. it recommended, I run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  3. brew upgrade mongosh
  4. brew update
  5. brew upgrade
  6. created a Users/MyUserNameOnMyMachine/data/db
  7. Edited my /usr/local/etc/mongod.conf/mongod.conf file to include:
    storage:
    #dbPath: /Users/Shared/Previously Relocated Items/Security/data/db
    dbPath: /Users/MyUserNameOnMyMachine/data/db

net:
bindIp: 0.0.0.0
port: 27017

In a terminal ran: brew services restart mongodb-community@4.0

All is well again!