---
title: "Connect Your Database - Documentation"
description: "A general overview of how database connections work, including security, permissions, and supported databases."
canonical: "https://www.aifordatabase.com/docs/connect-database/"
---

# Connect Your Database

beginner 4 min read

## Connecting Your Database

AI for Database supports a range of relational and document databases as well as spreadsheet-based data sources. This page covers the general concepts that apply to all connection types.

### Supported Databases

| Database | Status | Min Version |
| --- | --- | --- |
| PostgreSQL | GA | 12+ |
| MySQL | GA | 5.7+ |
| MongoDB | GA | 4.4+ |
| SQL Server | GA | 2017+ |
| Google Sheets | GA | N/A |
| SQLite | Beta | 3.35+ |

### Connection Security

Every connection is encrypted with TLS in transit. Credentials are stored using AES-256 encryption at rest and are never logged.

AI for Database connects with **read-only privileges by default**. We strongly recommend creating a dedicated database user that has only `SELECT` access. This ensures the AI can never modify your data, even if a prompt injection were attempted.

For self-hosted deployments, the connection never leaves your network. For our cloud product, connections go through our secure gateway which supports SSH tunnels, VPN peering, and IP allowlisting.

### Connection Settings

All database connections share these settings:

*   **Host / Endpoint** -- The hostname or IP address of your database server.
*   **Port** -- The port your database listens on (e.g., 5432 for PostgreSQL).
*   **Database Name** -- The specific database to connect to.
*   **Username & Password** -- Credentials for the read-only user you created.
*   **SSL Mode** -- Whether to require, prefer, or disable SSL.

Optional settings:

*   **SSH Tunnel** -- Connect through a bastion host for databases in private networks.
*   **Schema Filter** -- Limit which schemas or collections the AI can see.
*   **Connection Pool Size** -- Control the number of concurrent connections (default: 3).

### Testing Your Connection

After entering your credentials, click **Test Connection**. AI for Database will attempt to connect, list the available schemas and tables, and run a lightweight query (`SELECT 1`). If the test fails, you will see a detailed error message. See [Connection Troubleshooting](https://www.aifordatabase.com/docs/connection-troubleshooting/) for common fixes.

### Next Steps

Choose your specific database guide for detailed instructions:

*   [PostgreSQL](https://www.aifordatabase.com/docs/postgresql/)
*   [MySQL](https://www.aifordatabase.com/docs/mysql/)
*   [MongoDB](https://www.aifordatabase.com/docs/mongodb/)
*   [SQL Server](https://www.aifordatabase.com/docs/sql-server/)
*   [Google Sheets](https://www.aifordatabase.com/docs/google-sheets/)

Source: https://www.aifordatabase.com/docs/connect-database/
