# 9.3. Setting up MongoDB Connectors

**Introduction**

AI2SQL MongoDB connectors enable users to interact with MongoDB databases seamlessly. This help document guides users on how to provide their MongoDB credentials, including those from MongoDB Atlas, to connect with the AI2SQL platform.

\
**Prerequisites**

To use the AI2SQL MongoDB connectors, you must have the following:

* Access to the AI2SQL platform
* MongoDB server with valid credentials (host, port, username, password, and database) or MongoDB Atlas account

**Connecting to MongoDB using AI2SQL**

To connect to MongoDB using AI2SQL, follow these steps:

1. Log in to the AI2SQL platform with your username and password.
2. Navigate to the MongoDB connector section.
3. Enter your MongoDB credentials in the respective fields:
   * Host: The server address or domain where your MongoDB instance is running.
   * Port: The port number on which your MongoDB instance is listening (default is 27017).
   * Username: Your MongoDB username with appropriate permissions.
   * Password: Your MongoDB password associated with the username.
   * Database: The name of the MongoDB database you want to connect to.
4.  Click on the "Connect" button to establish a connection with your MongoDB instance.

    If the connection is successful, you will see a "Connection established" message. If there is an issue with the connection, you will receive an error message with details about the problem. Check your MongoDB credentials and try again.
5. Once connected, you can use the AI2SQL MongoDB connectors to fetch collections, query data, and perform other database-related tasks.\
   \


**Getting MongoDB Atlas Connection Details**

If you are using MongoDB Atlas, follow these steps to obtain your connection details:

1. Log in to your MongoDB Atlas account.
2. Navigate to the "Clusters" section.
3. Click on the "Connect" button for the cluster you want to connect to.
4. Choose "Connect your application."
5. Select "Python" as the driver and choose the appropriate version.
6.  Copy the connection string provided. It should look like this:

    ```
    mongodb+srv://<username>:<password>@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
    ```
7. Replace `<username>` and `<password>` with your MongoDB Atlas username and password, respectively.
8. Extract the following details from the connection string:
   * Host: The server address or domain (e.g., `cluster0.mongodb.net`)
   * Port: For MongoDB Atlas, the port is included in the connection string and is usually 27017.
   * Username: Your MongoDB Atlas username
   * Password: Your MongoDB Atlas password
   * Database: The database you want to connect to (replace `myFirstDatabase` with the desired database name)
9. Enter these details in the AI2SQL MongoDB connector form, as described in Section 3, and click "Connect."

**Troubleshooting and FAQs**

*   **Q: I cannot connect to my MongoDB instance. What should I do?**

    A: Check your MongoDB credentials and ensure that your MongoDB instance is running and accessible. Verify that your MongoDB server is allowing connections from the AI2SQL platform's IP address.
*   **Q: I received an authentication error. How can I resolve it?**

    A: Ensure that your MongoDB username and password are correct, and the user has the necessary permissions to connect to the specified database.



**Contacting Support**

If you encounter any issues while using the AI2SQL MongoDB connectors or need assistance with the configuration and setup, please don't hesitate to contact the AI2SQL support team. They can provide guidance and help troubleshoot any problems you may be experiencing.

To contact the AI2SQL support team, you can:

* Send an email to support@ai2sql.io with a detailed description of your issue or question. Please include any error messages, screenshots, or relevant information that can help diagnose the problem.
* Visit the AI2SQL support [portal](https://www.ai2sql.io/contact) and submit a support ticket. Make sure to provide as much information as possible about the issue you're facing.
* Reach out through the AI2SQL community forum (replace with your actual community forum URL), where you can ask questions and receive help from other users as well as the support team.

The AI2SQL support team will respond as quickly as possible to help you resolve any issues and ensure a smooth experience with the MongoDB connectors.

