MongoDB: MLab Databases, Users and Collections

Next steps after creating a database

The instructions on this page assume that you’ve:

The next step is to create at least one user, and at least one collection. This page will walk you through the process.

Start by clicking name of database

From the main menu of the, click the name of the database to get started, as shown:


Start by creating a database user

Your application will not be able to access your database unless you associate a user and password with it.

It is important to note: this is NOT the same as your username/password!

Instead, this is a username password that is ONLY used by an application in order to access the database.

You will typically record this username/password in a configuration file or environment variable. For example, when using Heroku, the value will likely be stored in one of the Config Variables for your application. It is considered bad practice to hard code this in code that you commit into a github repo, even a private one. Instead, put it in a configuration file that is in your .gitignore.

A good practice is to set up the password in a configuration file as a long random string of letters and digits, e.g.

export MONGO_DB_USER=corgisuser
export MONGD_DB_PASSWORD=e8gewFE273WFa9fE0wGe3j18

Then, when you create the user and password, you can copy paste from your configuration file.

To create the user, click on the Users tab on this screen:


Then, click to create a user:


Enter the information for the user, and click Create:


Add a collection

Finally, in order to use your new database, you will need at least one collection.

To create a collection:


Empty Collection, ready to use

You now have an empty collection, ready to use. It should look something like this:


Next Steps

Your next steps are to write some code that interacts with your newly created collection. The way you do that will depend on the programming language you are using to write your application.

More on MongoDB: MLab Databases, Users and Collections