|
| 1 | +--- |
| 2 | +type: "docs" |
| 3 | +title: "Configure MySQL Bootstrap Provider" |
| 4 | +linkTitle: "MySQL" |
| 5 | +weight: 45 |
| 6 | +description: "Bootstrap queries from a MySQL snapshot" |
| 7 | +related: |
| 8 | + howto: |
| 9 | + - title: "Configure Sources" |
| 10 | + url: "/drasi-server/how-to-guides/configuration/configure-sources/" |
| 11 | + - title: "Configure MySQL Source" |
| 12 | + url: "/drasi-server/how-to-guides/configuration/configure-sources/configure-mysql-source/" |
| 13 | + - title: "Configure Bootstrap Providers" |
| 14 | + url: "/drasi-server/how-to-guides/configuration/configure-bootstrap-providers/" |
| 15 | +--- |
| 16 | + |
| 17 | +The **MySQL bootstrap provider** loads initial state from a MySQL database so queries start with a complete snapshot before streaming begins. |
| 18 | + |
| 19 | +## When to use MySQL bootstrap |
| 20 | + |
| 21 | +- You need historical/current state from MySQL when a query starts. |
| 22 | +- Your query depends on existing rows (aggregations, joins, thresholds). |
| 23 | +- You want snapshot + binlog streaming from the same database. |
| 24 | + |
| 25 | +## Prerequisites |
| 26 | + |
| 27 | +- Use with a **MySQL source** (`sources[].kind: mysql`). |
| 28 | +- The database user must have **SELECT** permission on the configured tables. |
| 29 | +- The `tables` list is **required** — you must explicitly specify which tables to bootstrap. |
| 30 | + |
| 31 | +## Quick example (Drasi Server config) |
| 32 | + |
| 33 | +In Drasi Server config, bootstrap provider keys are **camelCase**, and the discriminator field is `bootstrapProvider.kind`. |
| 34 | + |
| 35 | +```yaml |
| 36 | +sources: |
| 37 | + - kind: mysql |
| 38 | + id: orders-db |
| 39 | + autoStart: true |
| 40 | + |
| 41 | + host: ${MYSQL_HOST:-localhost} |
| 42 | + port: ${MYSQL_PORT:-3306} |
| 43 | + database: ${MYSQL_DATABASE:-mydb} |
| 44 | + user: ${MYSQL_USER:-drasi_user} |
| 45 | + password: ${MYSQL_PASSWORD} |
| 46 | + |
| 47 | + tables: |
| 48 | + - orders |
| 49 | + - customers |
| 50 | + |
| 51 | + bootstrapProvider: |
| 52 | + kind: mysql |
| 53 | +``` |
| 54 | +
|
| 55 | +## Configuration reference |
| 56 | +
|
| 57 | +| Field | Type | Required | Description | |
| 58 | +|---|---|---:|---| |
| 59 | +| `kind` | string | Yes | Must be `mysql`. | |
| 60 | +| `host` | string | No | MySQL host (default: `localhost`). | |
| 61 | +| `port` | integer | No | MySQL port (default: `3306`). | |
| 62 | +| `database` | string | Yes | Database name to connect to. | |
| 63 | +| `user` | string | Yes | Database user with SELECT permission. | |
| 64 | +| `password` | string | No | Password (default: `""`). | |
| 65 | +| `tables` | string[] | Yes | Table allow-list for bootstrapping. Must contain at least one table. | |
| 66 | +| `tableKeys` | array | No | Override key columns per table (see below). | |
| 67 | + |
| 68 | +### tableKeys |
| 69 | + |
| 70 | +Use `tableKeys` to define key columns for element ID generation when primary keys are missing. |
| 71 | + |
| 72 | +```yaml |
| 73 | +bootstrapProvider: |
| 74 | + kind: mysql |
| 75 | + tableKeys: |
| 76 | + - table: order_items |
| 77 | + keyColumns: [order_id, product_id] |
| 78 | +``` |
| 79 | + |
| 80 | +## Notes |
| 81 | + |
| 82 | +- Drasi Server only allows `kind: mysql` when the source is also `kind: mysql`. |
| 83 | +- The `tables` list acts as a security allow-list — only tables explicitly listed will be bootstrapped. |
| 84 | +- Table names must use only letters, numbers, and underscores. |
| 85 | + |
| 86 | +## Documentation resources |
| 87 | + |
| 88 | +<div class="card-grid card-grid--2"> |
| 89 | + <a href="https://github.com/drasi-project/drasi-core/blob/main/components/bootstrappers/mysql/README.md" target="_blank" rel="noopener"> |
| 90 | + <div class="unified-card unified-card--tutorials"> |
| 91 | + <div class="unified-card-icon"><i class="fab fa-github"></i></div> |
| 92 | + <div class="unified-card-content"> |
| 93 | + <h3 class="unified-card-title">MySQL Bootstrap README</h3> |
| 94 | + <p class="unified-card-summary">Implementation notes and behavior details</p> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + </a> |
| 98 | + <a href="https://crates.io/crates/drasi-bootstrap-mysql" target="_blank" rel="noopener"> |
| 99 | + <div class="unified-card unified-card--howto"> |
| 100 | + <div class="unified-card-icon"><i class="fas fa-box"></i></div> |
| 101 | + <div class="unified-card-content"> |
| 102 | + <h3 class="unified-card-title">drasi-bootstrap-mysql on crates.io</h3> |
| 103 | + <p class="unified-card-summary">Package info and release history</p> |
| 104 | + </div> |
| 105 | + </div> |
| 106 | + </a> |
| 107 | +</div> |
0 commit comments