Registry / database / db-migrate-mysql8

db-migrate-mysql8

JSON →
library1.0.1jsnpmunverified

A MySQL driver for db-migrate that supports MySQL 5.x and 8.0.x. Version 1.0.1 is the latest stable release. This driver enables database migrations using the db-migrate framework with MySQL 8 features, including caching_sha2_password authentication. Low maintenance cadence. Key differentiator: specifically for MySQL 8 compatibility versus older db-migrate-mysql driver.

npm install db-migrate-mysql8
INSTALL
IMPORT
SIG · DB-MIGRATE-MYSQL8
D
db-migrate-mysql8
databasejavascriptv1.0.1
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
import DBMigrate from 'db-migrate'
const dbmigrate = require('db-migrate')
TypeScript/ESM usage; require works in CJS but ESM is recommended.
MYSQL8 Driver
import { MYSQL8 } from 'db-migrate-mysql8'
import MYSQL8 from 'db-migrate-mysql8'
Named export; default export is not provided.
getInstance
import { getInstance } from 'db-migrate-mysql8'
Factory function to create driver instance.

Initialize db-migrate with MySQL8 driver and apply all pending migrations.

import DBMigrate from 'db-migrate'; import { MYSQL8 } from 'db-migrate-mysql8'; const dbmigrate = DBMigrate.getInstance(true, { driver: MYSQL8, config: { host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '3306'), user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'mydb' } }); dbmigrate.up().then(() => { console.log('Migrations applied successfully.'); }).catch(err => { console.error('Migration failed:', err); });
Debug
Known issues
breakingMySQL 8 default authentication plugin 'caching_sha2_password' not supported by older mysql driver; this plugin uses mysql2 which supports it.
fix
Upgrade to db-migrate-mysql8 >=1.0.0 or ensure you use caching_sha2_password compatible client.
affects: <1.0.0
deprecateddb-migrate-mysql (original) is deprecated for MySQL 8; use db-migrate-mysql8 instead.
fix
Switch package from 'db-migrate-mysql' to 'db-migrate-mysql8'.
affects: >=0.0.0
gotchaDriver name in db-migrate config must be 'mysql8' not 'mysql'.
fix
Set driver to 'mysql8' in migration config JSON or programmatically.
affects: >=1.0.0
gotchaThis driver does not support MySQL 5.7 or earlier fully; some features may break.
fix
Use db-migrate-mysql for MySQL 5.7 compatibility.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'db-migrate-mysql8'
Package not installed or not in node_modules.
fix
Run: npm install db-migrate-mysql8
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
Old mysql client does not support MySQL 8 caching_sha2_password.
fix
Use mysql2 instead of mysql; or alter MySQL user to use mysql_native_password.
TypeError: Cannot destructure property 'driver' of 'undefined' or null.
db-migrate not properly initialized with driver instance.
fix
Ensure you pass driver instance: getInstance(true, { driver: MYSQL8 })
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
db-migrate-baserequiredRequired base class for migration drivers
mysql2requiredMySQL client library for Node.js
Agent activity
9 hits · last 30 days
node
8
Resources