How to connect MongoDB Compass using MLab connection string - mongodb

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:
What am I doing wrong?

Had same problem manage to solve it like this:
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

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.

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.

The required credentials are not your login credentials to MLab,
instead these are database user credentials.
How to get them:
click on your DB on MLab.
go to users tab and create new user.
use the created users credentials to access db.
set authenticationdatabase to be your database.

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

What I did:
Click on "Fill in connection fields individually" option in Compass.
Enter the hostname (Example ds051234.mlab.com)
Enter PORT (Example 12345)
Select Username/password in the Authentication option.
Enter username and password (Create a new user in mlab.com for your database)
Authentication Database (Just enter the "database name" in this field. Example: heroku_8967jgy5)
I hope this will help you.

Related

Trying To Connect to Native Mongo DB Driver

I'm trying to connnect to Mongo DB Driver and I am getting this error:
This is code I copy and pasted from the starter documents on the website. I changed the hostname to my first and last name and the uri connection to my server:
Any help is appreciated.
I have also faced this issue, while trying to create a demo app, I updated my password using autogenerate password, i.e I clicked on auto generate password and pasted it in connection string, it worked for me.
Instead of mongodb+srv:// you should be using mongodb://
DNS SeedList Format
mongodb+srv requires additional settings on DNS which contains seedlist, commonly use for sharded clusters and replica set
https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-dns-seedlist
Standard Connection String Format
If you are connecting to a standalone you should be using the standard connection string format.
mongodb://<username>:<password>:<IP/Hostname>:<Port>/<database>
https://docs.mongodb.com/manual/reference/connection-string/#standard-connection-string-format
Creating User with Password
To create a username with password you should be using db.createUser() which can be found here.
https://docs.mongodb.com/manual/reference/method/db.createUser/
Example ( To create a Admin user )
use admin;
db.createUser({
username: 'brianlevin',
pwd: passwordPrompt(),
roles: [ { role: 'admin', db: 'databasename' }]
})

Connecting to MongoDB Without Credentials in AWS Glue

I am trying to move my data in MongoDB to Redshift using AWS Glue. To do this, I am trying to add a connection to MongoDB. My MongoDB setup does not have credentials configured. But the Username and Password fields in the Add Connection page are mandatory. Test Connection fails on giving dummy values as they will be considered during the authentication process. Would appreciate any help in this regard.
To be upfront I haven't tried this myself, but to remove the requirement for Username and Password is easy.
Basically in the Migration Setup Wizard in the "Authentication mode" drop-down box select "none". Default value is "password, where the username and password is mandatory.
Hope that assist.

Connecting to MongoDB database on mLab fails authentication

I have a Parse app, and I'm trying to migrate my app's database to a MongoDB instance on mLab.
I already have a fork of Parse Server set up on Heroku, and I'm using Heroku's mLab MongoDB add-on.
I have a database on mLab called heroku_1ksph3jj, and I should be able to connect to it with the following template:
mongodb://<dbuser>:<dbpassword>#ds047124.mlab.com:47124/heroku_1ksph3jj
However, each attempt returns:
Server returned error on SASL authentication step: Authentication failed.
I'm unsure what to replace <dbuser> and <dbpassword> with. I have a database user with the same name as my database: heroku_1ksph3jjz, so I used that. And I used the password for that user in place of <dbpassword>. Should I have used something else here?
You can get the dbuser and dbpass with:
heroku config | grep MONGODB_URI
Grab the dbuser (example_user) and dbpass (example_pass) from the response:
MONGOLAB_URI: mongodb://example_user:example_pass#mlab.com:12345/db
As of March 2016, mLab.com only supports mongo 3.0+ (as per a conversation with support), because of their new onerous authentication requirements.
This was not on the website, but I hope it helps someone here!
There's a message to create a user for the specific database:
A database user is required to connect to this database. To create one now, visit the 'Users' tab and click the 'Add database user' button
I'm so sorry that this may seem obvious but, you have to remove this characters <> for the migration to work
In your example would look like this:
mongodb://dbuser:dbpassword#ds047124.mlab.com:47124/heroku_1ksph3jj
Check your mongo client version. If it is in older major version (probably 2.x), update it to 3.x
For future visitors - don't use special characters in password .Even if you change the special character to ascii or unicode it wont work for mLab using mongoose.
Also don't use mLab credential , use db user credentials . I created a new user.
Eg. For me a password containing # character was replaced with ascii value %40 in URI , which worked when using native mongodb driver.
But on using mongoose, i was always getting Authentication Failed .
I removed special characters and db was authenticated via mongoose.
It looks like it was the password that was incorrect, which I'm assuming was set up by Heroku's mLab add-on. There was no obvious way to reset this in the mLab UI, so in the end I created another database user (with a new username and password) and was able to connect with that just fine.
Just go to your Heroku dashboard and check your settings.
Under the name field there's a big button "Reveal Config Vars". Click it and you'll see a MONGODB_URI var with a uri to your db. It'll look something like this:
mongodb://heroku_user:PASSWORDyourLOOKINGfor#ds2238985.mlab.com:63295/heroku_user
Your password is right after the semicolon after the heroku user name.
I know I am too late, just for information.
For getting the info of mLab account that got auto created when mLab addon got added to the application in your heroku account, try the below command.
heroku config:get MONGODB_URI
Ref:
http://algebra.sci.csueastbay.edu/~grewe/CS6320/Mat/NodeJS/Heroku/Heroku_MLabMongoDB.html

Connecting to MongoLab shell (Azure cloud server)

So i spent quite a bit of time pulling my hair out trying to connect to our MongoLab account at work with a command line shell. I followed the instructions here but no for some reason mongoDB would always return: Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails"}
My user name and password were coming from my database under the users collections which worked fine with my Node.js driver but wouldn't work with my shell.
The question is: where does one find the correct user name and password to connect to MongoLabs with the mongodb shell.
Turns out the user name and password to connect and authorize with the shell aren't found in MongoLabs but in Azure's portal.
Log into your Azure account, in the left column scroll down to Add-Ons and click.
You should see a MongoLab's. Go ahead and click on that.
From there click on Connection Info at the bottom of the window and it will display a string similar to this:
mongodb://username:password#ds012345.mongolab.com:56789/mongolab
go ahead and copy and paste that username and password into your shell with this command :
mongo ds012345.mongolab.com:56789/dbname -u dbuser -p dbpassword
NOTE: Your command will look different because you're using a different MongoLabs account.

not able to connect to mongodb because of unauthorized lock type

I am trying to connect to my mongodb deployed in jelastic cloud
If i try to use the test database already provided in the mongodb node in jelastic..it works fine.But if i create my own database and try to access the collections created in it ..i get the following exception
com.mongodb.MongoException: unauthorized db:appdb lock type:-1 client:192.168.1.53
Why is this happening?how can i resolve it?
I am reading the configuration from a file mydb.cfg
host=mongodb-***.jelastic.servint.net
dbname=appdb
user=admin
password=*****
When in Rock Mongo web interface pick the targeted db and go for 'More' in config panel.
This has to show you the list of users having rights for DB.
Did you set the user and rights for your custom collection?
Try to check the configuration under 'Authentication' section?
Anyway, supposedly admin user should have rights to all DBs. You can try to figure this issue out at Jelastic community
I had the same issue when connection to mongodb custom named database.
In order to succeed with the connection, I have created an user for my custom named database.
(I added the provided admin user with its password to the authorized users as the image shown).