Registry / database / mysql-server

mysql-server

JSON →
library1.0.5jsnpmunverified

A Node.js package that provides an isolated, portable MySQL server (or MariaDB) for development and testing. It bundles MySQL binaries and automatically manages starting and stopping a local instance without requiring a separate MySQL installation. The current version is 1.0.5, but the project appears to be minimally maintained with limited configuration options (port, credentials, etc.) and no active release cadence. Key differentiators: standalone execution without a system MySQL install; synchronous start (blocks the process). Consider alternatives like 'mysql2' or 'mysqld' for more robust development database solutions.

npm install mysql-server
INSTALL
IMPORT
SIG · MYSQL-SERVER
M
mysql-server
databasejavascriptv1.0.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 mysqlServer = require('mysql-server');
import mysqlServer from 'mysql-server';
This package only supports CommonJS require. No ESM or TypeScript definitions provided.
start
mysqlServer.start();
start() is synchronous and blocks the Node.js process until the server is stopped.
stop
mysqlServer.stop();
stop() kills the MySQL server process.

Demonstrates starting the bundled MySQL server, connecting with mysql2, running a query, and stopping the server.

const mysqlServer = require('mysql-server'); const mysql = require('mysql2'); // or mysql mysqlServer.start(); // blocks until Ctrl+C // In another process, connect: const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'test' }); connection.query('SELECT 1', (err, results) => { if (err) throw err; console.log(results); }); connection.end(); mysqlServer.stop();
Debug
Known issues
gotchastart() is synchronous and blocks the Node.js event loop - your script will hang until the server is stopped.
fix
Run start() in a separate child process or use the package only for background testing.
affects: >=1.0.0
gotchaNo configuration options available - port, username, password are hardcoded (port 3306, user root, no password).
fix
If you need custom config, consider alternatives like 'mysql2' or a proper MySQL installation.
affects: >=1.0.0
deprecatedThe package is not actively maintained; issues and feature requests may not be addressed.
fix
Evaluate whether this package meets long-term needs or switch to 'mysql2' or 'dockerode' with MySQL Docker container.
affects: >=1.0.0
gotchaFirst run may be slow due to unzipping MySQL binaries - expect a delay of several seconds.
fix
Be patient; subsequent starts are faster.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql-server'
Forgetting to install the package or using wrong import syntax.
fix
Run: npm install mysql-server
EACCES: permission denied, open '/usr/local/lib/node_modules/mysql-server/bin/mysqld'
Missing execute permissions on MySQL binary or running without sufficient privileges.
fix
Run: sudo chmod +x /path/to/mysqld or install the package globally with npm (not recommended).
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
MySQL server is not running or socket path is different.
fix
Ensure mysqlServer.start() was called and wait a few seconds for the server to initialize.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mysql-server — npm install mysql-server · libregistry