How to connect MongoDB Compass using MLab connection string
Asked Answered
K

6

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?

Kelbee answered 14/9, 2018 at 20:57 Comment(0)
S
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

Sicilia answered 29/12, 2018 at 13:18 Comment(4)
For me, Authentication Database is the problem.Theologize
The main thing was Authentication Database, that was admin by default.Julietajulietta
This should be set as correct answer! Solved my problemFledgy
Solved! Still I don't understand why we need to create another database user.Phobia
A
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.

Agrology answered 22/9, 2018 at 11:7 Comment(1)
Yes,"Authentication Database" means "the database you want to connect to".Minutiae
P
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.

Protective answered 17/12, 2018 at 20:45 Comment(1)
Yes, that was exactly the case for me too!Santee
S
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.

Solvent answered 28/9, 2018 at 21:39 Comment(0)
D
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

Diaghilev answered 27/10, 2018 at 4:13 Comment(0)
B
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.

Benevento answered 13/6, 2020 at 13:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.