Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect MongoDB Compass using MLab connection string

Tags:

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?

like image 857
Digvijay Avatar asked Sep 14 '18 20:09

Digvijay


People also ask

How do I connect to a MongoDB connection?

To connect to a MongoDB Server using username and password, you have to use 'username@hostname/dbname'. Where username is the username, password is the password for that user and dbname is the database to which you want to connect to. Note : You can use multiple hostname to connect to with a single command.

Can't connect to MongoDB using Compass?

Ensure Your MongoDB Instance is Running Compass must connect to a running MongoDB instance. Make sure you have installed MongoDB and have a running mongod process. You should also check that the port where your MongoDB instance is running matches the port you provide in the Compass connect dialog.


2 Answers

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

like image 129
elad BA Avatar answered Sep 19 '22 23:09

elad BA


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.

like image 28
Philippe Matray Avatar answered Sep 23 '22 23:09

Philippe Matray