Overview
MySQL dialect that uses the mysql2 library. This dialect works with both MySQL and MariaDB databases. Source:src/dialect/mysql/mysql-dialect.ts:43
Installation
Install the required peer dependency:Basic Usage
Configuration
MysqlDialectConfig
Source:src/dialect/mysql/mysql-dialect-config.ts:8
A mysql2 Pool instance or a function that returns one.If a function is provided, it’s called once when the first query is executed. This allows for lazy initialization of the connection pool.See mysql2 pool documentation for available pool options.
Called once for each created connection. Useful for setting up connection-level configuration.
Called every time a connection is acquired from the connection pool. Use this for per-query setup.
Connection Pooling
The MySQL dialect uses themysql2 library’s built-in connection pooling. Here are recommended pool settings:
SSL/TLS Configuration
To connect using SSL:Streaming Results
The MySQL dialect supports streaming large result sets:Character Set and Collation
Configure character set and collation for your connection:Timezone Handling
MySQL connections default to the server’s timezone. To use UTC:Multiple Statements
To execute multiple statements in a single query:MariaDB Compatibility
TheMysqlDialect works with MariaDB databases. Simply point it to your MariaDB server:
Related Types
MysqlPool
Source:src/dialect/mysql/mysql-dialect-config.ts:37
The subset of the mysql2 Pool interface that Kysely requires:
MysqlPoolConnection
Source:src/dialect/mysql/mysql-dialect-config.ts:44
MysqlOkPacket
Source:src/dialect/mysql/mysql-dialect-config.ts:66
Result type for INSERT, UPDATE, and DELETE queries: