MySQL database adapter for the Koishi chatbot framework (v3.6.2). Provides persistent storage for user data, sessions, and application state via MySQL/MariaDB. Updated on the same cadence as Koishi core (~monthly). Differentiators: native integration with Koishi's ORM-style query API, full TypeScript types, and zero-config setup within Koishi projects. Alternatives like direct mysql2 usage lack Koishi's plugin lifecycle management.
npm install koishi-plugin-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a Koishi application with MySQL database adapter using environment variables for configuration.
Update koishi-core to ^3.14.2.
Use ES module imports (import/import()) or enable ESM in your project.
Place MySQL config under database.mysql in the Koishi constructor options.
Use ctx.database inside command handlers or after start.
Define models via ctx.model() and the plugin creates tables automatically.
Install koishi-plugin-mysql@3 and update config accordingly.
Change to ES module import: import mysql from 'koishi-plugin-mysql';
Ensure app = new Koishi(options) before calling app.plugin().
Verify MYSQL_USER, MYSQL_PASSWORD environment variables or config values.
CREATE DATABASE koishi; or change database name in config.
Change database port in config (database.mysql.port) or stop conflicting service.