logo

Constatic

Discord Bot BaseGuidesDatabasesMongoDB

MongoDB

Guide to create a new mongodb database

Creating a MongoDb Database

Visit https://www.mongodb.com/pt-br and log in (or register).

step-01

You should be sent to the home page. If not, click the Atlas logo at the top of the page After that, click on New Project to create a new project

step-02

Enter the name you want and click Next

step-03

You will see this screen, so just click Create Project

step-04

You will be redirected to your project home screen

Initially you will have nothing, so click Create

step-05

Choose the M0 free plan

step-06

Choose the provider you want, then select the region (It is recommended to choose the one closest to your application). Enter whatever name you prefer for the cluster.

step-07

At the bottom of the page click Create

step-08
  • ⚠️ This step is very important

Create a user to be able to access the database! Set the name you want and the password (It is recommended to click to generate the password automatically).

  • ⚠️ Click to copy this password and save it for later use Keep scrolling down the page and you will reach the last step
step-09

Add an IP address and click Add Entry Adding the IP 0.0.0.0/0 will allow your bot that is hosted anywhere to connect to the database

Lastly click on Finish and Close

step-10

Click Connect

step-11

Then select Drivers

step-12

Click to copy your database URI

step-13

Note that right below it says to replace <password> with the password you defined for your user

  • mongodb+srv://root:<password>@cluster0.doy8zej.mon...
  • mongodb+srv://root:T8g4Hrlqi7LUK0XG@cluster0.doy8zej.mon...

With your database URI in hand, you can now use it in your projects to connect.

Define it in the .env file

step-14

On this page