> For the complete documentation index, see [llms.txt](https://docs.ilert.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ilert.com/ai-and-agents/mcp/hosted/mysql.md).

# MySQL

Give an agent read-only access to MySQL schemas and server metrics through the ilert MCP connector.

#### Required permissions

<table><thead><tr><th width="177.515625">Tool</th><th width="178.515625">Required Permission</th><th>Description</th></tr></thead><tbody><tr><td><code>list_databases</code></td><td><code>SELECT</code></td><td>List all databases in the MySQL server. Useful for discovering available databases.</td></tr><tr><td><code>list_tables</code></td><td><code>SELECT</code></td><td>List all tables in a specific database. Useful for discovering available tables and their structure.</td></tr><tr><td><code>describe_table</code></td><td><code>SELECT</code></td><td>Get detailed schema information about a table including columns, data types, indexes, and constraints.</td></tr><tr><td><code>get_metrics</code></td><td><code>PROCESS</code>, <code>REPLICATION CLIENT</code></td><td>Get MySQL metrics in one call: InnoDB stats, current process list, replication status, connection counts, and lock information. Useful for diagnosing long-running queries, deadlocks, and replication lag.</td></tr></tbody></table>

{% hint style="info" %}
The MySQL integration is read-only and does not expose an arbitrary SQL query tool. The agent can inspect schemas and read server metrics, but it cannot access your data.
{% endhint %}

#### Create MySQL user

Using the MySQL MCP server requires a MySQL user with specific read-only privileges. The connector performs the following operations:

* `SHOW DATABASES` - List all databases
* `SHOW TABLES FROM <database>` - List tables in a database
* `DESCRIBE <database>.<table>` - Get table schema
* `SHOW TABLE STATUS` - Get table metadata
* `SHOW STATUS` / `SHOW GLOBAL STATUS` - Get MySQL status variables
* `SHOW VARIABLES` / `SHOW GLOBAL VARIABLES` - Get MySQL configuration variables
* `SHOW PROCESSLIST` - View current queries and connections
* `SHOW SLAVE STATUS` / `SHOW MASTER STATUS` - View replication status
* `SHOW ENGINE INNODB STATUS` - View InnoDB status and lock information

**Required Privileges:**

The user needs the following privileges:

1. **PROCESS** - Required for `SHOW PROCESSLIST` and `SHOW ENGINE INNODB STATUS`
2. **REPLICATION CLIENT** - Required for `SHOW SLAVE STATUS` and `SHOW MASTER STATUS`
3. **SELECT** - Required for `SHOW DATABASES`, `SHOW TABLES`, `DESCRIBE`, and `SHOW TABLE STATUS` on databases you want to query

**Note:** The following operations work WITHOUT additional privileges:

* `SHOW STATUS` / `SHOW GLOBAL STATUS` - works for all users
* `SHOW VARIABLES` / `SHOW GLOBAL VARIABLES` - works for all users

**Important:** `SHOW DATABASES` only shows databases that the user has privileges on. To see and query databases, you need to grant SELECT privilege on them.

**Example SQL Script:**

```sql
-- Create the user
CREATE USER IF NOT EXISTS 'ilert_mcp_connector'@'%' IDENTIFIED BY 'your_secure_password_here';

-- Grant global privileges for monitoring
GRANT PROCESS ON *.* TO 'ilert_mcp_connector'@'%';
GRANT REPLICATION CLIENT ON *.* TO 'ilert_mcp_connector'@'%';

-- Grant SELECT on all databases (read-only access)
-- Option 1: Grant on all databases
GRANT SELECT ON *.* TO 'ilert_mcp_connector'@'%';

-- Option 2: Grant on specific databases only (more secure)
-- GRANT SELECT ON `database1`.* TO 'ilert_mcp_connector'@'%';
-- GRANT SELECT ON `database2`.* TO 'ilert_mcp_connector'@'%';

-- Apply changes
FLUSH PRIVILEGES;

-- Verify grants
SHOW GRANTS FOR 'ilert_mcp_connector'@'%';
```

{% hint style="warning" %}
**Security Note:**

* `SELECT` privilege is read-only - the user cannot modify data
* For maximum security, grant SELECT only on specific databases you need to monitor
* If you need to monitor all databases, use `GRANT SELECT ON *.*`
  {% endhint %}

#### Deploy the ilert MCP connector

ilert does not connect to your MySQL server directly. The MySQL MCP server calls the **ilert MCP connector**, a service you deploy in your own network and expose over a public HTTPS URL. Deployment, the auth token and all configuration options are on its own page:

{% content-ref url="/pages/cKuRiKPs7NQX5toTeOJo" %}
[ilert MCP connector](/ai-and-agents/mcp/ilert-mcp-connector.md)
{% endcontent-ref %}

Enable MySQL on the connector with these variables:

```bash
MYSQL_ENABLED=true
MYSQL_HOST=mysql.internal
MYSQL_PORT=3306
MYSQL_USER=ilert_mcp_connector
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=information_schema
```

`MYSQL_DATABASE` only sets the default database for the connection — the agent addresses other databases by name, as long as the user has `SELECT` on them.

#### Connect MySQL with agent

To connect MySQL with your AI SRE agent:

{% stepper %}
{% step %}
Navigate to **Agents** in the ilert navigation menu
{% endstep %}

{% step %}
Open the agent detail view for the agent you want to configure
{% endstep %}

{% step %}
Go to the **Tools** tab
{% endstep %}

{% step %}
Under the **ilert hosted MCP servers** section, locate the **MySQL** card
{% endstep %}

{% step %}
Click **Connect** on the MySQL card
{% endstep %}

{% step %}
In the connection dialog that appears:

* **Select connector:** Choose "Create new connector" (or select an existing connector if you have one)
* **Type:** Select **Bearer Token** from the dropdown
* **Secret name:** Enter a name for your connector (e.g., "MySQL Production" or "MySQL Main")
* **Secret value:** Enter the `AUTH_TOKEN` value from your connector deployment
* **Host URL:** Enter the public URL where your connector is reachable (e.g., `https://ilert-mcp-connector.example.com`)
  {% endstep %}

{% step %}
Click **Connect** to complete the connection
{% endstep %}

{% step %}
After connecting, you can enable or disable specific tools needed for alert investigation, such as:

* `list_databases` - List all databases in the MySQL server
* `list_tables` - List all tables in a specific database
* `describe_table` - Get detailed schema information about a table
* `get_metrics` - Get InnoDB stats, process list, replication status, connections, and locks
  {% endstep %}
  {% endstepper %}

The MySQL integration is now connected and ready to use for root cause analysis.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ilert.com/ai-and-agents/mcp/hosted/mysql.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
