Registry / database / mysqli

mysqli

JSON →
library3.1.4jsnpmunverified

MySQL tool that converts SQL syntax to MongoDB-like API, based on the `node-mysql` module. Current stable version is 3.1.4. Provides simple APIs for common CRUD operations and includes protection against XSS injection. Designed to be beginner-friendly. Alternatives include `mysql2` and `mysql`. Release cadence is irregular.

npm install mysqli
INSTALL
IMPORT
SIG · MYSQLI
M
mysqli
databasejavascriptv3.1.4
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.

Mysqli
const Mysqli = require('mysqli')
import Mysqli from 'mysqli'
mysqli is a CommonJS module; ESM import is not supported directly
default
const conn = new Mysqli({...})
import { Mysqli } from 'mysqli'
The package exports a single constructor function as default
connection
let conn = new Mysqli(config)
const conn = Mysqli.connect(config)
Instantiate directly with new — no static connect method

Instantiates a MySQL connection and runs a simple query using the callback style.

const Mysqli = require('mysqli'); let conn = new Mysqli({ host: 'localhost', post: 3306, user: 'root', passwd: process.env.DB_PASS ?? '' }); let db = conn.get('mydb', 'master'); db.query('SELECT 1 + 1 AS solution', (err, rows) => { if (err) throw err; console.log('The solution is: ', rows[0].solution); });
Debug
Known issues
gotchaConnection config uses 'post' (typo) instead of 'port' for the port number
fix
Use 'post' key (with 'post' being the misspelled name) or provide both 'post' and 'port'
affects: >=3.0.0
deprecatedv2.x is deprecated and no longer maintained
fix
Upgrade to v3.x via 'npm i mysqli@3.x'
affects: 2.x
breakingv3.x removed the old callback patterns for some methods; now requires Promise or callback with different signatures
fix
Refer to v3 documentation at docs/3.x.md for updated API signatures
affects: >=3.0.0
gotchaMultiple configs: the first config is used as master, others as slaves — order matters
fix
Ensure the first config in the array corresponds to the primary database server
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module 'mysqli'
Package not installed or installed in wrong directory
fix
Run 'npm install mysqli' in the project root
Mysqli is not a constructor
Using import statement instead of require, or importing incorrectly
fix
Use 'const Mysqli = require('mysqli')' instead of 'import Mysqli from 'mysqli''
ER_ACCESS_DENIED_ERROR: Access denied for user
Invalid credentials or missing privileges
fix
Check user, password, and host in the config; ensure the user has access from the connecting host
Upgrade
Version history
3.1.4latest on npm
Audit
Dependencies
mysqlrequiredmysqli is built on top of the node-mysql module, which is a peer dependency
Agent activity
4 hits · last 30 days
node
4
Resources
packagemysqli
mysqli — npm install mysqli · libregistry