Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 796
Adam Colvin Avatar asked Mar 18 '16 10:03

Adam Colvin


2 Answers

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:[email protected]:12345/db

like image 80
Imjohsep Avatar answered Oct 26 '22 11:10

Imjohsep


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!

like image 32
lol Avatar answered Oct 26 '22 11:10

lol