MongoDB: MLab Databases, Users and Collections
Next steps after creating a database
The instructions on this page assume that you’ve:
- already done the initial set up steps on the page MongoDB: MLab to sign up for an mlab account, and create a so-called “new private environment”
- created a database, following the instructions at MongoDB: MLab Database Creation
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 https://mlab.com, 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 mlab.com 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:
- Click on the Collections tab, and then click the button to create a new collection.
- Enter a name for the collection, as shown below, then click Create:
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
- MongoDB: Java—Accessing MongoDB via Java
- MongoDB: MLab—A specific cloud provider of MongoDB services
- MongoDB: MLab Database Creation—Setting up a new database
- MongoDB: MLab Databases, Users and Collections—Next steps after creating a database
- MongoDB: Python—Accessing MongoDB via Python
- MongoDB: Spring Boot (Java)—Accessing MongoDB via Spring Boot