MongoDB: Creating a Cluster using Atlas
Follow these instructions to set up a database for your project. You will want to go to the Get Started with Atlas guide and follow those instructions.
Create an Atlas Account
Start by creating an account in MongoDB Atlas.
- Go here
- Fill out the First Name, Last Name, Email, and Password fields, or Sign Up with Google
- Agree to the terms and service and submit
- Fill out the form in any way desired, and click the "Finish" button
Deploy a Database Cluster
Now that you have an account, it should automatically redirect you to the database deployment page.
- Select the M0 free option
- Click the "Create" button
- Prove you are not a robot if needed
Set Up the Database
Now that the database has been created, you will need to setup access rules.
- Under "Security Quickstart" with "Username and Password" selected, enter a username and password
- Feel free to use the "Autogenerate Secure Password" button - just make sure to copy/remember the password!
- Click "Create User"
- Scroll down to the "Where would you like to connect from?" section
- Click the "Add My Current IP Address" button
- Click the "Finish and Close" button
- In the popup, click the "Go to Databases" button
Get a Connection String
Now the database should be ready to go! You just need a special URL to connect your application to it.
- In the "Cluster0" deployment click the "Connect" button
- In the popup that appears, click the "Drivers" button
- Make sure "Node.js" is selected as the driver
- Click the copy button next to the connection string
Update the .env File
Now all that's left is putting the string into the back-end/.env file in the project. This file should have been created during the environment setup by following the instructions in the repository README.
- In the back-end/.env file, remove the string after
MONGO_URI=
- In its place, paste in the copied connection string surrounded by quotes
- Replace
<password>
with the password for the user you created (make sure to get rid of the<
and>
)
That should be it! You should now be able to connect to your MongoDB Database from the application.