Installing the Index Advisor agent for MySQL
The Index Advisor agent collects MySQL database metadata to provide index optimization recommendations. This guide covers the prerequisites and installation steps.
Prerequisites
Before installing the Index Advisor agent, ensure you have:
- MySQL 5.7 or later - Required for performance schema and query digest support.
- A database user with appropriate permissions - The agent needs read-only access to performance schema and system tables.
- Helm CLI installed - Used to deploy the agent into your Kubernetes cluster.
- kubectl configured - With access to the cluster where you want to run the agent.
Step 1: Create a database user for the agent
Create a dedicated MySQL user that the Index Advisor agent will use to connect to your database.
CREATE USER 'index_advisor_agent'@'%' IDENTIFIED BY 'your_secure_password_here';
NoteReplace
'your_secure_password_here'with a strong, unique password. The'%'host wildcard allows connections from any host — restrict this to the agent's IP or subnet in production environments if needed.
Step 2: Grant required permissions
The agent requires read-only access to query statistics and schema metadata. Run the following statements as a MySQL superuser:
Grant SELECT access on the Performance Schema, which the agent uses to collect query statistics:
GRANT SELECT ON performance_schema.* TO 'index_advisor_agent'@'%';Grant SELECT access on the database you want to analyze. This allows the agent to retrieve schema metadata via information_schema:
GRANT SELECT ON your_database.* TO 'index_advisor_agent'@'%';
NoteIf you want to analyze multiple databases, repeat the second
GRANTstatement for each one. All permissions are read-only — the agent never modifies your database schema or data.
Step 3: Enable Index Advisor in the console
Index Advisor is enabled per cache, not per database. Your database must have a DBO cache group defined in the console before you can proceed — the cache does not need to be deployed to a cluster. If you haven't created one yet, see Getting started with DBO.
Once your cache is in place:
- In the Cast AI console, go to Database → Index Advisor.
- Select the cache associated with the database you want to analyze.
- Click Enable.
The console will display Helm installation instructions specific to your cache, including your API key and database identifier.
Step 4: Install the agent via Helm
Follow the Helm installation instructions provided in the console.
Using Kubernetes secrets for credentials (recommended)
For production deployments, store credentials in Kubernetes secrets instead of passing them directly to the Helm chart.
API key secret
Create a secret containing your Cast AI API key:
kubectl create secret generic castai-db-agent-api-key \
--namespace castai-db-optimizer \
--from-literal=API_KEY='your-api-key-here'Database credentials secret
Create a secret containing your database credentials:
kubectl create secret generic castai-db-agent-db-credentials \
--namespace castai-db-optimizer \
--from-literal=DATABASE_USERNAME='index_advisor_agent' \
--from-literal=DATABASE_PASSWORD='your_secure_password_here'Then reference them in your values.yaml for the Helm chart:
apiKeySecretRef: castai-db-agent-api-key
database:
host: "your_database_host"
port: 3306
name: "your_database_name"
credentialsSecretRef: castai-db-agent-db-credentialsAdd the Cast AI Helm repository and install the agent:
helm repo add castai-helm https://castai.github.io/helm-charts
helm repo update
helm install castai-db-agent castai-helm/castai-db-agent \
--namespace castai-db-optimizer \
--create-namespace \
--values values.yamlTo verify the agent is running:
kubectl get pods -n castai-db-optimizerOnce the agent is healthy, it will begin collecting query statistics and index metadata. Recommendations will appear in the Cast AI console within a few minutes.
Updated about 15 hours ago
