# MongoDB Setup

***

### Step 1: Create an Account

#### Visit MongoDB Cloud:

1. **Open your web browser** and navigate to [MongoDB Cloud.](https://www.mongodb.com/products/platform/cloud)

#### Sign Up:

2. **Click on the Sign Up button**.
3. **Enter your email address and create a password**.
4. Alternatively, you can sign up using your **Google account**.

#### Accept Privacy Policy & Terms:

5. **Read through the Privacy Policy & Terms**.
6. **Check the box to accept them and proceed**.

#### Answer "Getting to Know You" Questions:

7. You will be presented with a few questions to help MongoDB understand your needs.
8. You can answer these questions randomly as they do not affect your setup.

***

### Step 2: Deploy Your Cluster

#### Choose the Free Tier:

1. After logging in, you will be directed to the **MongoDB Atlas dashboard**.
2. **Click on Build a Cluster**.
3. Select the **M0 (Free) tier option**.

#### Cluster Configuration:

**Name Your Cluster:**

4. You can leave the default name as **Cluster0** or choose a custom name.

**Cloud Provider & Region:**

5. Choose **AWS** as your cloud provider.
6. Select a region closest to you. (**Frankfurt** is recommended for European users).
7. Click **Create Cluster** to begin the deployment process.

***

### Step 3: Set Up a Database User

#### Create a Database User:

1. While your cluster is being created, you will need to set up a database user.
2. Go to the **Database Access tab**.
3. **Click on Add New Database User**.

#### Set a Username & Password:

4. Enter a username of your choice.
5. Create a strong password and make a note of it as you will need it later.
6. Click **Add User** to create the database user.

***

### Step 4: Choose a Connection Method

#### Connect to Your Cluster:

1. Once your cluster is created, go to the **Clusters view**.
2. **Click on the Connect button** for your cluster.

#### Choose a Connection Method:

3. Select **Connect Your Application**.

**Drivers:**

4. Select Drivers
5. Copy the connection string provided.

{% hint style="success" %}
**Note:** Ensure the connection string starts with `mongodb+srv://`.
{% endhint %}

#### Update Your Configuration File:

6. Open your **core.yml** file
7. Paste the connection string into the file.
8. Replace `<password>` in the connection string with the password you noted down earlier.

{% hint style="danger" %} <mark style="color:red;">I</mark><mark style="color:red;">**mportant:**</mark> Make sure to remove **`< >`**
{% endhint %}

***

### Step 5: Configure Network Access

#### Add IP Address:

1. Navigate to the **Network Access tab**.
2. **Click on Add IP Address**.
3. Enter the IP address of the server where you will be hosting your bot or application.
4. If you want to allow access from anywhere, you can add `0.0.0.0/0`, but this is not recommended for security reasons.
5. Click **Confirm** to add the IP address.

***

### Common Issues and Troubleshooting

#### Buffer Timeout

**Whitelist IP Address:**

1. Ensure your server's IP is whitelisted under the **Network Access tab**.

**Correct Password:**

2. Verify that the password you are using in the connection string is correct.
3. If you have forgotten your password, you can reset it in the **Database Access tab**:
   * Go to **Database Access**.
   * Click **Edit** next to the user.
   * Enter a new password and save the changes.
