> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MySQL

> Database connection for MySQL

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Use this to connect Alumio to a MySQL database server. Once it is set up, the connection can be reused by other features that read from or write to your MySQL database, so you configure where the server lives and how to sign in just once. The extra MySQL options let you tune how the connection behaves, but the defaults work for most servers.

This documentation describes: [Schema](/schemas/database-connection/mysql)

## Fields

<FormField property="host" label="Host" required>
  The address of the MySQL server, for example `db.example.com`. This can be a domain name or an IP address.
</FormField>

<FormField property="port" label="Port">
  The network port the server listens on. If you leave this empty it defaults to `3306`, the standard MySQL port. Change it only if your server uses a different port.
</FormField>

<FormField property="dbname" label="Database name" required>
  The name of the database on the server that you want to work with.
</FormField>

<FormField property="charset" label="Character set">
  The character set used when reading and sending data, for example `utf8mb4` or `latin1`. Leave it empty unless your database expects a specific encoding.
</FormField>

<FormField property="username" label="Username">
  The username used to sign in to the database server. Leave it empty to connect anonymously.
</FormField>

<FormField property="password" label="Password">
  The password used to sign in. You can reference an environment variable here instead of typing the secret directly.
</FormField>

<FormField property="options.MYSQL_ATTR_INIT_COMMAND" label="MySQL: Init command">
  A statement that runs automatically each time the connection is opened, for example `SET NAMES utf8`. Use it to put the session into a known state before any of your own queries run.
</FormField>

<FormField property="options.MYSQL_ATTR_COMPRESS" label="MySQL: Network compression">
  Compresses the data sent between Alumio and the server. On by default. This can speed up transfers of large result sets over slower connections.
</FormField>

<FormField property="options.MYSQL_ATTR_MULTI_STATEMENTS" label="MySQL: Multi query execution">
  Allows several statements separated by semicolons to run in a single query. On by default.
</FormField>

## Sample data

A typical MySQL connection:

| Field         | Value                      |
| ------------- | -------------------------- |
| Host          | `your-db-host.example.com` |
| Port          | `3306`                     |
| Database name | `warehouse`                |
| Character set | `utf8mb4`                  |
| Username      | `integration_user`         |
| Password      | `your-password`            |

```json theme={null}
{
    "host": "your-db-host.example.com",
    "port": 3306,
    "dbname": "warehouse",
    "charset": "utf8mb4",
    "username": "integration_user",
    "password": "your-password"
}
```

Connection credentials are shown here as placeholders. For the password you can reference an environment variable instead of typing the secret directly; see [Placeholders](/references/placeholders) for the full syntax.

```json Configuration theme={null}
{
  "prototype": "mysql",
  "parameters": {
    "host": "your-db-host.example.com",
    "port": 3306,
    "dbname": "warehouse",
    "charset": "utf8mb4",
    "username": "integration_user",
    "password": "your-password"
  }
}
```
