Skip to content

MySQL connector

MySQL is reached over the MySQL wire protocol with the mysql crate. Statements go over the text protocol on purpose — the same adapter serves TiDB, StarRocks and Doris, where prepared-statement support is patchy — and results are normalized into the shared ResultSet shape.

Connections are pooled (8 by default) and opened lazily. Gated by the exec-mysql cargo feature.

Connection profile

datasources:
  mysql_prod:
    type: mysql
    host: ${MYSQL_HOST}
    port: 3306
    username: dosi
    password: ${MYSQL_PASSWORD}
    database: analytics

Or as a single DSN:

datasources:
  mysql_prod:
    type: mysql
    uri: mysql://dosi:${MYSQL_PASSWORD}@mysql.internal:3306/analytics

Parameters

Key Type Required Default Notes
type string yes mysql
host string yes* *Unless uri: is given.
port int no 3306
username string no
password string no Prefer ${VAR}; a literal warns on stderr.
database string no The schema compiled table names resolve against.
uri string no A full mysql:// DSN. It replaces the discrete keys: when uri: is set, host, port, username, password and database are ignored.
default bool no false See connection profiles.

Parsed and ignored on this connector: sslmode, sslrootcert (this adapter has no TLS handling at all), schema, catalog, arrow_flight_port, account, role, warehouse, compat_mode.

Two driver settings are fixed rather than exposed: Unix-socket preference is off (so host: localhost really does connect over TCP), and client connection attributes are cleared, which some proxies and forks reject.

Limitations

  • No FULL OUTER JOIN — but this is not a query limitation. A multi-branch merge (several metrics at different grains) is lowered to the portable UNION-keys CTE + LEFT JOIN shape instead, the same one the PostgreSQL family uses. Nothing changes in your model.
  • No 3-argument DATEDIFF. MySQL's DATEDIFF takes two dates; a metric written with the unit-first 3-argument form is refused at compile time for this dialect.
  • No CORR / COVAR_*. These are absent from MySQL entirely, so correlation windows are refused rather than approximated.
  • No TLS. The profile's sslmode/sslrootcert are ignored here; put the connection on a trusted network or in front of a proxy that terminates TLS.

Verify the connection

$ dosi query --model model.yaml \
    --metrics revenue --group-by orders.status --execute --connection mysql_prod

Troubleshooting

Message Cause and fix
connection "x": bad url: <e> The uri: is not a valid mysql:// DSN.
cannot reach server: <io error> Host, port or network — nothing was answered.
An auth error carrying the server's own text (error 1045, 1044 or 1698) Wrong credentials, no rights on the database, or an auth plugin the account requires (auth_socket accounts cannot be used over TCP).
server rejected SQL (<code>): <message> MySQL refused the compiled statement; the code and text are MySQL's.
this build has no mysql executor (feature "exec-mysql" not enabled) Published binaries include it; a hand-built one needs --features exec-mysql.

Reference