MySQL
The MySQL connector turns approved relational rows into searchable documents. It supports two indexing modes:
- Automatic discovery reads accessible base tables in the selected database, lets administrators select tables and columns, and maps rows into documents.
- Custom SQL runs a controlled
SELECTorWITHquery and maps returned columns into document ID, title, searchable content, metadata, and update time.
Use a dedicated read-only account and expose only curated tables or views. Do not connect a broad production account to a database that contains unapproved personal data, credentials, tokens, or operational secrets.
What You Need
Create a Read-Only MySQL Account
Run grants from a database administrator account. Adjust host pattern, database, table, and view names to match your environment.
MySQL supports account-level TLS requirements such as REQUIRE SSL. Enable them for this account only when your AIvis deployment path provides compatible MySQL TLS handling, for example through an approved private database proxy.
Create views when the source tables contain sensitive columns:
Use database-level grants only for a database that is already curated for AIvis indexing:
Create the Credential
The connector uses utf8mb4 when reading MySQL rows and sets a 10-second connection timeout.
Choose an Indexing Mode
Automatic Discovery
Automatic discovery reads accessible base tables in the selected database and ignores MySQL system schemas such as information_schema, mysql, performance_schema, and sys.
In the schema tree:
- Select only tables and fields that are approved for indexing.
- Binary, geometry, and blob-like columns are not indexed.
- AIvis uses primary keys first, then non-null unique indexes, then a row hash when no stable key exists.
- Tables without a stable key can create new document IDs when selected values change; prefer adding a primary key or using Custom SQL with an explicit ID.
- The default title field is inferred from columns such as
title,name,subject, orlabel; you can override it in table settings. - The update field is inferred from datetime columns such as
updated_at,updated,modified_at,modified, orlast_modified; no update field means the table requires full scans.
Custom SQL Requirements
The connector wraps your query as a subquery and validates returned columns. Keep the SQL read-only and deterministic.
Example:
For this query, set:
Production Safety
The connector opens MySQL reads in a read-only transaction and sets max_execution_time during reads. That protects AIvis from writing data, but it does not replace database-side controls.
Before production:
- Use a replica, analytics database, or curated view layer when possible.
- Add indexes that support your Custom SQL filters and update window.
- Avoid
SELECT *in Custom SQL; explicitly return only approved columns. - Avoid long-running joins against hot OLTP tables.
- Keep batch size modest until query plans and sync duration are measured.
- Restrict the MySQL account host pattern to the AIvis network path rather than
%. - Do not enforce account-level MySQL TLS requirements until the deployed connection path supports them; use private networking or an approved proxy for protected routes.
- Verify that query plans do not create heavy locks, full scans on large tables, or excessive temporary tables.
Verification
- Confirm the credential connects with the read-only account.
- In Automatic discovery, confirm the expected database tables and fields appear.
- In Custom SQL, validate that the query returns every configured column.
- Run an initial sync and inspect row count, indexed document count, and failures.
- Search for representative records by title and content.
- Confirm unselected tables, fields, and sensitive columns are absent from search.
- Update one test row and confirm the same document updates when an update field is configured.
- Test as a user outside the connector audience and confirm restricted documents do not appear.