3

I am new to Heroku and MongoDB. I created a Heroku app which has an added-on MongoDB by MongoLab.

Everything was set up automatically by Heroku. When I navigated to MongoLab database manager page (SSO protected) it showed a standard MongoDB URL as:

mongodb://<dbuser>:<dbpassword>@dsxxxxxx.mongolab.com:39674/heroku_xxxxxxxx

Those "x" letters represents numbers.

I didn't bother to specify a dbuser and dbpassword at all. So what is the dbuser and dbpassword?

alextc
  • 3,206
  • 10
  • 63
  • 107

4 Answers4

4

None of these answers are correct, if you want to know your URI to your database go to your project in heroku and look at settings, reveal config vars and you find all the URI

Config Vars of Heroku project reveals MLab or other Add ons URIs

Ben Smith
  • 521
  • 3
  • 15
  • The format is `mongodb://:@.mlab.com:/` So just use the stuff before the `:` and before the `@` if you only need the dbuser and dbpassword! – dTanMan Nov 12 '19 at 10:09
2

In your terminal, navigate to your project folder and type $ heroku config:get MONGODB_URI to get your Heroku provisioned username and password.

R. Alfonso
  • 21
  • 4
1

Mongolab provides you with database hosting services using MongoDB as the database engine. This means you have to have a subscription to their services, in order to have access to a MongoDB database. Once you sign up for one of their plans you will have your own database username and database password to authenticate database connections with.

So dbuser will be your MongoDb username and dbpassword will be your MongoDB password. You use these elements to gain access to your own databases and collections.

https://mongolab.com/plans/pricing/

Bob Cochran
  • 150
  • 2
  • 11
1

When you create a MongoLab add-on for your Heroku app, a MONGOLAB_URI environment variable is automatically created with connection info for your database add-on:

https://devcenter.heroku.com/articles/mongolab#getting-your-connection-uri

pneumee
  • 494
  • 3
  • 8