# MySQL (/integrations/mysql)

Use cases and templates: [MySQL integration for AI agents](https://www.sim.ai/integrations/mysql)





<BlockInfoCard type="mysql" color="#FFFFFF" />

{/* MANUAL-CONTENT-START:intro */}

Use [MySQL](https://www.mysql.com/) to query rows, insert or modify records, execute raw SQL, and inspect databases, tables, columns, keys, and indexes. Configure the host, port, database, credentials, and SSL mode for the target server.

Query returns rows and a row count. Insert, update, and delete operations accept the data or WHERE clause documented below. Raw SQL can also change schema; use a database account with the permissions the workflow needs.

{/* MANUAL-CONTENT-END */}

## Use the block [#usage-instructions]

Query, insert, update, delete, and execute raw SQL.

## Actions [#actions]

### MySQL Query [#mysql-query]

Execute SELECT query on MySQL database

#### Input [#input]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `host` | string | Yes | MySQL server hostname or IP address |
| `port` | number | Yes | MySQL server port (default: 3306) |
| `database` | string | Yes | Database name to connect to (e.g., my\_database) |
| `username` | string | Yes | Database username |
| `password` | string | Yes | Database password |
| `ssl` | string | No | SSL connection mode (disabled, required, preferred) |
| `query` | string | Yes | SQL SELECT query to execute (e.g., SELECT \* FROM users WHERE active = 1) |

#### Output [#output]

| Parameter | Type | Description |
| - | - | - |
| `message` | string | Operation status message |
| `rows` | array | Array of rows returned from the query |
| `rowCount` | number | Number of rows returned |

### MySQL Insert [#mysql-insert]

Insert new record into MySQL database

#### Input [#input-1]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `host` | string | Yes | MySQL server hostname or IP address |
| `port` | number | Yes | MySQL server port (default: 3306) |
| `database` | string | Yes | Database name to connect to (e.g., my\_database) |
| `username` | string | Yes | Database username |
| `password` | string | Yes | Database password |
| `ssl` | string | No | SSL connection mode (disabled, required, preferred) |
| `table` | string | Yes | Table name to insert into (e.g., users, orders) |
| `data` | object | Yes | Data to insert as key-value pairs |

#### Output [#output-1]

| Parameter | Type | Description |
| - | - | - |
| `message` | string | Operation status message |
| `rows` | array | Array of inserted rows |
| `rowCount` | number | Number of rows inserted |

### MySQL Update [#mysql-update]

Update existing records in MySQL database

#### Input [#input-2]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `host` | string | Yes | MySQL server hostname or IP address |
| `port` | number | Yes | MySQL server port (default: 3306) |
| `database` | string | Yes | Database name to connect to (e.g., my\_database) |
| `username` | string | Yes | Database username |
| `password` | string | Yes | Database password |
| `ssl` | string | No | SSL connection mode (disabled, required, preferred) |
| `table` | string | Yes | Table name to update (e.g., users, orders) |
| `data` | object | Yes | Data to update as key-value pairs |
| `where` | string | Yes | WHERE clause condition (without WHERE keyword) |

#### Output [#output-2]

| Parameter | Type | Description |
| - | - | - |
| `message` | string | Operation status message |
| `rows` | array | Array of updated rows |
| `rowCount` | number | Number of rows updated |

### MySQL Delete [#mysql-delete]

Delete records from MySQL database

#### Input [#input-3]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `host` | string | Yes | MySQL server hostname or IP address |
| `port` | number | Yes | MySQL server port (default: 3306) |
| `database` | string | Yes | Database name to connect to (e.g., my\_database) |
| `username` | string | Yes | Database username |
| `password` | string | Yes | Database password |
| `ssl` | string | No | SSL connection mode (disabled, required, preferred) |
| `table` | string | Yes | Table name to delete from (e.g., users, orders) |
| `where` | string | Yes | WHERE clause condition (without WHERE keyword) |

#### Output [#output-3]

| Parameter | Type | Description |
| - | - | - |
| `message` | string | Operation status message |
| `rows` | array | Array of deleted rows |
| `rowCount` | number | Number of rows deleted |

### MySQL Execute [#mysql-execute]

Execute raw SQL query on MySQL database

#### Input [#input-4]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `host` | string | Yes | MySQL server hostname or IP address |
| `port` | number | Yes | MySQL server port (default: 3306) |
| `database` | string | Yes | Database name to connect to (e.g., my\_database) |
| `username` | string | Yes | Database username |
| `password` | string | Yes | Database password |
| `ssl` | string | No | SSL connection mode (disabled, required, preferred) |
| `query` | string | Yes | Raw SQL query to execute (e.g., CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255))) |

#### Output [#output-4]

| Parameter | Type | Description |
| - | - | - |
| `message` | string | Operation status message |
| `rows` | array | Array of rows returned from the query |
| `rowCount` | number | Number of rows affected |

### MySQL Introspect [#mysql-introspect]

Introspect MySQL database schema to retrieve table structures, columns, and relationships

#### Input [#input-5]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `host` | string | Yes | MySQL server hostname or IP address |
| `port` | number | Yes | MySQL server port (default: 3306) |
| `database` | string | Yes | Database name to connect to (e.g., my\_database) |
| `username` | string | Yes | Database username |
| `password` | string | Yes | Database password |
| `ssl` | string | No | SSL connection mode (disabled, required, preferred) |

#### Output [#output-5]

| Parameter | Type | Description |
| - | - | - |
| `message` | string | Operation status message |
| `tables` | array | Array of table schemas with columns, keys, and indexes |
| `databases` | array | List of available databases on the server |
