Create an account on MongoLab.
NOTE: When you create your MongoLab account, you may give them a user name and password. These are not the username and password that your programs will use to access your database. The credentials for accessing your database need to be set up separately in another step.
If you don't have one already, or if one is not created for you automatically, create a database. Go to the page associated with that database. Near the top, notice information like this:
To connect using the mongo shell: mongo ds049848.mongolab.com:49848/elvenlab01 -u
-p To connect using a driver via the standard MongoDB URI (what's this?): mongodb:// : @ds049848.mongolab.com:49848/elvenlab01
You care about the second of these two statements. In particular, you care about the URL that looks like this:
Click on Users. Click on Add Database User. Add a database user. These are the credentials you will use to access your database.
Suppose your user name was foo and your password was bar. Here is how to compose a URL to use in your code to access your database:
Of course the database name and the numbers will be different in your case, but the basic rhythm of the URL is the same.
Two screen shots: