Registry / database / marv-mysql-driver

marv-mysql-driver

JSON →
library5.0.0jsnpmunverified

A MySQL driver for the marv database migration library (v5.0.0). This package provides a MySQL connection driver for executing SQL migrations managed by marv. It supports both mysql and mysql2 npm packages as peer dependencies, automatically detecting which is installed. Released under the MIT license, it follows a regular release cadence with contributions from the community. Key differentiators include support for both Promise and callback APIs, automatic driver detection, and built-in troubleshooting for MySQL 8 authentication issues.

npm install marv-mysql-driver
INSTALL
IMPORT
SIG · MARV-MYSQL-DRIVER
M
marv-mysql-driver
databasejavascriptv5.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const driver = require('marv-mysql-driver')
import driver from 'marv-mysql-driver'
Package uses CommonJS; no default ESM export
marv (Promise API)
const marv = require('marv/api/promise')
const marv = require('marv')
marv core exports callback API by default; use marv/api/promise for Promise support
marv (Callback API)
const marv = require('marv/api/callback')
const marv = require('marv')
Same as default; shown for clarity

Shows how to run SQL migrations using marv with the mysql driver, using async/await and environment variables for connection config.

const marv = require('marv/api/promise'); const driver = require('marv-mysql-driver'); const path = require('path'); const directory = path.resolve('migrations'); const connection = { host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test', multipleStatements: true }; async function runMigrations() { const migrations = await marv.scan(directory); await marv.migrate(migrations, driver({ connection })); console.log('Migrations completed successfully'); } runMigrations().catch(err => { console.error('Migration failed:', err); process.exit(1); });
Debug
Known issues
gotchamysql v8 uses caching_sha2_password which is not supported by the mysql npm package; use mysql2 or configure MySQL to use mysql_native_password
fix
Install mysql2: npm install mysql2, or change MySQL authentication plugin to mysql_native_password
affects: <=5.0.0
gotchaDriver requires multipleStatements: true in connection options, otherwise multi-statement migrations will fail
fix
Set multipleStatements: true in the connection object
affects: >=4.0.0
breakingVersion 5.x drops support for Node.js < 14
fix
Upgrade Node.js to >=14.0.0
affects: >=5.0.0
Errors
Common errors & fixes
Client does not support authentication protocol requested by server; consider upgrading MySQL client
MySQL 8 default auth plugin caching_sha2_password not supported by mysql package
fix
Use mysql2 instead of mysql, or set default_authentication_plugin=mysql_native_password in MySQL config
Cannot find module 'mysql'
marv-mysql-driver requires either mysql or mysql2 but neither is installed
fix
npm install mysql or npm install mysql2
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
marvrequiredCore migration library; marv-mysql-driver is a driver for marv
mysqloptionalOne of the two supported MySQL client libraries; must be installed separately
mysql2optionalOne of the two supported MySQL client libraries; must be installed separately
Agent activity
7 hits · last 30 days
node
6
Resources
marv-mysql-driver — npm install marv-mysql-driver · libregistry