23

I have database hosted on MLab and I am trying to connect it with Compass. I am using host and port given in connection string but it is showing error, here is my screenshot:

Compass

What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
Digvijay
  • 2,887
  • 3
  • 36
  • 86

6 Answers6

45

Had same problem manage to solve it like this:

mLab user tab

A. Go to your db in mlab and in the tab choose "users"

B. Create a new user ex: username: admin password: 123456

C: Go to compass and fill it this way

Example of your connection path

ds012345.mlab.com:56789/myDBname

hostname

ds012345.mlab.com

port

56789

authentication: username /password

admin // or the name of the user you created in step A
123456 // or password for the user you created in step A

authentication database

myDBname // the name of your database in mlab

Tomas Vancoillie
  • 3,463
  • 2
  • 29
  • 45
elad BA
  • 1,760
  • 11
  • 17
12

I just had the same problem.

I fixed it by updating my version of MongoDB Compass. No problems encountered with version 1.15.4.

Also, Authentication Database should not have the value "admin" but the name of the DB to connect you.

To make your connection easier, don't hesitate to copy your entire connection string into the clipboard. Compass detects it and proposes to automatically fill in the connection form.

Philippe Matray
  • 1,511
  • 1
  • 13
  • 22
10

The problem that I had was the Authentication Database Compass filled in automatically wasn't correct for my setup. By default, this was pointing to admin but it needs to point to the database that the user is associated with.

Summed up: The database of admin didn't exist.

Just to rule it out, double check what database you're pointing to. It should be in the name, like ds739176/database_name where database_name is, you guessed it, the name of your database.

Hope this helps.

Scott
  • 772
  • 1
  • 11
  • 20
4

The required credentials are not your login credentials to MLab, instead these are database user credentials.

How to get them:

  1. click on your DB on MLab.

  2. go to users tab and create new user.

  3. use the created users credentials to access db.

  4. set authenticationdatabase to be your database.

Mohammed Essehemy
  • 2,006
  • 1
  • 16
  • 20
3

I had the same problem. MongoDB url was working in code but Authentication failed was showing in MongoDB Compass.

When I checked, my mongodb password was iam%40me1234.

Here I'm using %40 HTML hex code in the password for @ character.

So, If we will use the original character in the password like iam@me1234 in MongoDB Compass then it will work great.

Here is a full list of Hex codes

Arpit
  • 1,423
  • 1
  • 17
  • 20
0

What I did:

  1. Click on "Fill in connection fields individually" option in Compass.
  2. Enter the hostname (Example ds051234.mlab.com)
  3. Enter PORT (Example 12345)
  4. Select Username/password in the Authentication option.
  5. Enter username and password (Create a new user in mlab.com for your database)
  6. Authentication Database (Just enter the "database name" in this field. Example: heroku_8967jgy5)

I hope this will help you.

nitin.agam
  • 1,949
  • 1
  • 17
  • 24