Create a MongoDB Atlas account
Once you open the MongoDB Atlas page, you should sign in / register for a new account
After logged into your new account click Create a cluster
under Shared Clusters
Create a new cluster
• Choose your cloud provider and region, you can leave this as the default provided (typically AWS).
• Customize your cluster's specs, you can also leave this as the default provided, M0 Sandbox (Shared RAM, 512 MB Storage) Encrypted
.
• Give your cluster a name, you can also leave this as the default provided, Cluster 0
• Now click the green Create Cluster button at the bottom of the screen and verify the image captions they provide.
• You should now see the message, Your cluster is being created - New clusters take between 1-3 minutes to provision
. Wait until the cluster is created before going to the next step
Create a new user on the database
• Click on Database Access
Under SECURITY
tab on the left side of the screen
• Under Database User
tab click on big green Add New Database User
button
• Enter a user name
and password
and then select Read or write to any database
under user privileges, remember to store your username and password somewhere safe.
• Click on the Add User
green button in the bottom right of the modal.
Note: You can always upgrade your privileges to the Admin level, however, it is best practice to give permissions to a user on an as-needed basis for security reasons.
Whitelist your IP address
On the left side, Under SECURITY
click on Network Access
Click on green Add IP Address
button under under IP Whitelist
tab
In the modal, click the ALLOW ACCESS FROM ANYWHERE
button and you should see 0.0.0.0/0
pre-filled for the whitelist entry field, click the green Confirm
button
**Connect to your cluster
Click on Clusters
under DATA STORAGE
Follow the instructions by clicking on the CONNECT
button in the Sandbox section
In the pop-up modal, click on Connect Your Application
, a connection string will be displayed, you can copy that connection string by clicking on the copy
button.
This will be the final URI that you will use to connect to your db, it will look something like this mongodb+srv://<user>:<password>@<cluster#-dbname>...
, notice that the user and cluster#-dbname fields are already filled out for you, all you would need to replace is the password
field with the one that you created in the previous step
That's it! You now have the URI you will add to your application to connect to your database. Keep this URI safe somewhere, so you can use it later!
Top comments (0)