mysql-memory-server is a JavaScript/TypeScript library designed to spin up ephemeral MySQL databases programmatically, primarily for testing, continuous integration, and local development. It automatically downloads the necessary MySQL binaries from MySQL's CDN if a specified version is not already installed on the system, supporting a wide range of MySQL versions from 5.7.19 up to 9.6.0. The package supports Linux, macOS, and Windows environments, including Alpine Linux. It is actively maintained with frequent releases, often introducing support for the latest MySQL versions and fixing platform-specific issues. The current stable version is 1.14.1. Key differentiators include its ability to manage multiple concurrent database instances, automatic shutdown upon process exit, and robust cross-platform compatibility.
npm install mysql-memory-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to spin up an ephemeral MySQL instance, connect to it using `mysql2/promise`, run a simple query, and then properly shut down the database. Requires `mysql2` as a separate dependency.
Install required system packages, e.g., `sudo apt-get install libnuma-dev libaio-dev` on Ubuntu before running.
Increase the timeout for your test suite or individual tests. For Jest, use `jest.setTimeout(ms)` in your setup file or test block.
Upgrade your Node.js runtime to 16.6.0 or newer. Consider using a version manager like nvm or fnm.
Ensure you are using `mysql-memory-server` version 1.12.2 or newer, especially if running on Windows with Node.js 23.x.
Increase the timeout settings for your test runner (e.g., `jest.setTimeout(30000)` for Jest) or for the operation itself.
Upgrade to `mysql-memory-server` v1.12.1 or newer, which contains a fix for this specific Windows-related issue.
Upgrade to `mysql-memory-server` v1.13.0 or newer, which addresses this lock-release bug on Alpine Linux.
Update to `mysql-memory-server` v1.12.2 or higher to resolve database stopping errors on Windows with Node.js 23.x.
Upgrade to `mysql-memory-server` v1.10.0 or higher to ensure compatibility and correct database startup on Windows Server 2025.
No dependency data recorded yet.