MongoDB
Guide to create a new mongodb database
Creating a MongoDb Database
Visit https://www.mongodb.com/pt-br and log in (or register).
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
Enter the name you want and click Next
You will see this screen, so just click Create Project
You will be redirected to your project home screen
Initially you will have nothing, so click Create
Choose the M0 free plan
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.
At the bottom of the page click Create
- ⚠️ 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
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
Click Connect
Then select Drivers
Click to copy your database URI
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