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: localhostDatabase server hostname or IP address
Portintegerdefault: 3306MySQL server port
Databasestringdefault: requiredName of the database to connect to
Usernamestringdefault: requiredDatabase user with read access
Passwordstringdefault: requiredUser password (stored encrypted)
SSL Enabledbooleandefault: falseEnable SSL/TLS connection
SSL CAstringdefault: nonePath to CA certificate (optional)
Charsetstringdefault: utf8mb4Character set for the connection
Sync Settings
Tablesarraydefault: all tablesSpecific tables to sync (empty = all)
Text columnsobjectdefault: auto-detectColumns to index per table
Timestamp columnstringdefault: noneColumn for incremental sync (e.g., updated_at)
Batch sizeintegerdefault: 1000Rows per batch (100-10,000)
Auto-Detected Column Types
These column types are automatically indexed as searchable text:
TEXT,MEDIUMTEXT,LONGTEXT,TINYTEXTVARCHAR,CHARENUM,SET
These column types are excluded automatically:
BLOB,MEDIUMBLOB,LONGBLOB,TINYBLOBBINARY,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: 1523Becomes 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: AccountIncremental 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_TIMESTAMPMariaDB 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
- In RAG Chats, delete the MySQL data source
- Optionally, revoke the database user's permissions:
DROP USER 500">class="text-green-500">'ragchats_reader'@500">class="text-green-500">'%';

