MySQL Integration

Connect to MySQL databases and sync table data to your knowledge base. Works with MySQL, MariaDB, and compatible databases.

How It Works

The MySQL connector reads data from your database tables and converts rows into searchable text documents. Each row becomes a document that your bot can reference when answering questions.

  • Automatically discovers tables and columns
  • Extracts text from text-like columns (VARCHAR, TEXT, MEDIUMTEXT, etc.)
  • Skips binary and blob columns automatically
  • Supports selective table and column sync
  • Enables incremental sync via timestamp columns

Read-Only Access

RAG Chats only reads data from your database. We never modify, insert, or delete any records.

Connecting MySQL

Add Database Source

From Knowledge Base, click + Add Source MySQL.

Enter Connection Details

Provide your database connection information:

  • Host: Database server address
  • Port: Usually 3306
  • Database: Database name
  • Username: Database user
  • Password: User password

Configure SSL (Optional)

For production databases, enable SSL:

  • Enable SSL connection checkbox
  • Optionally provide CA certificate path

Select Tables

After connecting, select which tables to sync. You can sync all tables or choose specific ones.

Configure Columns (Optional)

By default, all text-like columns are indexed. You can customize which columns to include for each table.

Start Sync

Click Connect to begin syncing. Large tables are processed in batches.

Connection Settings

Hoststringdefault: localhost

Database server hostname or IP address

Portintegerdefault: 3306

MySQL server port

Databasestringdefault: required

Name of the database to connect to

Usernamestringdefault: required

Database user with read access

Passwordstringdefault: required

User password (stored encrypted)

SSL Enabledbooleandefault: false

Enable SSL/TLS connection

SSL CAstringdefault: none

Path to CA certificate (optional)

Charsetstringdefault: utf8mb4

Character set for the connection

Sync Settings

Tablesarraydefault: all tables

Specific tables to sync (empty = all)

Text columnsobjectdefault: auto-detect

Columns to index per table

Timestamp columnstringdefault: none

Column for incremental sync (e.g., updated_at)

Batch sizeintegerdefault: 1000

Rows per batch (100-10,000)

Auto-Detected Column Types

These column types are automatically indexed as searchable text:

  • TEXT, MEDIUMTEXT, LONGTEXT, TINYTEXT
  • VARCHAR, CHAR
  • ENUM, SET

These column types are excluded automatically:

  • BLOB, MEDIUMBLOB, LONGBLOB, TINYBLOB
  • BINARY, VARBINARY

Example: Row to Document

A database row like this:

SELECT * FROM knowledge_base WHERE id = 1;

-- id: 1
-- title: 500">class="text-green-500">"How to reset password"
-- content: 500">class="text-green-500">"To reset your password, click the 'Forgot Password500">class="text-green-500">' link..."
-- category: 500">class="text-green-500">"Account"
-- views: 1523

Becomes a searchable document:

Table: knowledge_base
title: How to reset password
content: To reset your password, click the 500">class="text-green-500">'Forgot Password' link...
category: Account

Incremental Sync

For tables with a timestamp column (like updated_at), you can enable incremental sync:

  • Only new or modified rows are synced on subsequent runs
  • Dramatically reduces sync time for large tables
  • The timestamp of the last sync is stored automatically

Timestamp Column

Use a column that updates whenever the row changes. In MySQL, you can use:

updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

MariaDB Compatibility

The MySQL connector is fully compatible with MariaDB. Simply use your MariaDB connection details as you would with MySQL.

Security Best Practices

  • Create a read-only user: Never use root or admin credentials
  • Limit table access: Grant SELECT only on needed tables
  • Use SSL: Enable SSL for production databases
  • IP allowlisting: Restrict database access to RAG Chats IPs
  • Exclude sensitive data: Don't sync tables with PII or secrets

Example: Creating a Read-Only User

-- Create a dedicated user 500">for RAG Chats
CREATE USER 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%' IDENTIFIED BY 500">class="text-green-500">'secure_password';

-- Grant read-only access to specific tables
GRANT SELECT ON mydb.products TO 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%';
GRANT SELECT ON mydb.articles TO 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%';
GRANT SELECT ON mydb.faqs TO 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%';

-- Or grant access to all tables in a database
GRANT SELECT ON mydb.* TO 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%';

-- Apply changes
FLUSH PRIVILEGES;

Troubleshooting

Connection failed

  • Verify host, port, database name, and credentials
  • Check if the MySQL server allows remote connections (bind-address)
  • Ensure firewall rules allow the connection
  • Verify SSL settings if SSL is required

Access denied

  • Verify the user has SELECT permission on the tables
  • Check the user's host restriction (e.g., '%' for any host)
  • Ensure the password is correct

Character encoding issues

  • Ensure the connection charset matches your data (default: utf8mb4)
  • Verify your tables use UTF-8 encoding

No data synced

  • Verify tables contain text columns
  • Check if tables are empty
  • Ensure selected tables exist

Sync is slow

  • Reduce the number of tables being synced
  • Use incremental sync with a timestamp column
  • Increase batch size for faster processing
  • Add an index on your timestamp column

Removing the Integration

  1. In RAG Chats, delete the MySQL data source
  2. Optionally, revoke the database user's permissions:
    DROP USER 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%';