Registry / database / mysql-plugin

mysql-plugin

JSON →
library1.2.5jsnpmunverified

A Promise-based MySQL client wrapper around the 'mysql' npm package, using Bluebird for promise functionality. Version 1.2.5 is the latest stable release; the package appears to be sporadically maintained with infrequent updates. It differentiates itself by providing a simple drop-in Promise interface for the callback-based 'mysql' package, but lacks TypeScript definitions and has known issues with connection pooling and modern Node.js versions. Consider using 'mysql2' with promise support instead.

npm install mysql-plugin
INSTALL
IMPORT
SIG · MYSQL-PLUGIN
M
mysql-plugin
databasejavascriptv1.2.5
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 MySql = require('mysql-plugin')
import MySql from 'mysql-plugin'
ESM import not supported; package uses CommonJS only
init
require('mysql-plugin').init({...})
MySql.init({...})
init is not exported as a method of the main export; must be called via require().init() or via the main export's method after assignment
query
MySql.query('SELECT 1')
MySql.query('SELECT 1', callback)
Result is a Promise; do not pass a callback

Shows initialization with environment variables and an async query with error handling.

const MySql = require('mysql-plugin'); const { init } = require('mysql-plugin'); init({ host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' }); async function main() { try { const rows = await MySql.query('SELECT * FROM users'); console.log(rows); } catch (err) { console.error(err); } } main();
Debug
Known issues
gotchaThe package wraps the old 'mysql' package which is no longer actively maintained and lacks support for newer MySQL authentication (caching_sha2_password).
fix
Use 'mysql2' directly with its built-in promise support instead.
affects: >=1.0.0
gotchaThe 'init' function must be called before any queries. If not called, queries will fail with 'Connection not initialized' error.
fix
Always call require('mysql-plugin').init({...}) at startup.
affects: >=1.0.0
breakingThe query method does not support multiple statement executions or prepared statements.
fix
Use a raw string for single SQL statements only.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Connection not initialized
The 'init' function was never called before attempting a query.
fix
Call require('mysql-plugin').init({...}) at application startup.
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
MySQL 8+ uses 'caching_sha2_password' which the old 'mysql' package does not support.
fix
Upgrade to mysql2 or use a default auth plugin in MySQL: ALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password';
Upgrade
Version history
1.2.5latest on npm
Audit
Dependencies
bluebirdrequiredUsed for Promise implementation; a core dependency of the library
mysqlrequiredThe underlying MySQL client driver being wrapped
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-plugin — npm install mysql-plugin · libregistry