MySQL2

Fast, pure-JavaScript MySQL client for Node.js with prepared statements, promises, and pooling.

Library
npm
v3.23.3
4,382stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
94/100Excellent
Development Activity100
Maintenance96
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
90/100Excellent
Architecture90
Code Quality90
Innovation88
Learning Curve80

MySQL2 is a high-performance MySQL client for Node.js written entirely in JavaScript, with no native bindings to compile or install. It is a continuation of MySQL-Native with a protocol parser rewritten from scratch, and it is largely API-compatible with the popular mysqljs/mysql driver while adding faster performance and a broader feature set.

Beyond basic querying, MySQL2 supports server-side prepared statements, a promise-based API, connection pooling and pool clusters, SSL/TLS, protocol compression, extended encoding and collation handling, the MySQL binary log protocol, and even acting as a MySQL server. It powers a large share of the Node.js ecosystem and is the underlying driver for many ORMs and query builders.

What You Get

  • A pure-JavaScript MySQL/MariaDB driver that installs without native compilation
  • Both callback and promise-based APIs, plus connection pooling and pool clusters
  • Server-side prepared statements for safer, faster repeated queries
  • SSL/TLS, protocol compression, authentication switch, and AWS SSL profiles
  • Extended encoding/collation support and the MySQL binary log protocol
  • Near drop-in compatibility with the mysqljs/mysql API

Common Use Cases

  • Backing web and API servers that read from and write to MySQL or MariaDB
  • Serving as the low-level driver under ORMs and query builders such as Sequelize, Drizzle, and Knex
  • Running high-throughput workloads that benefit from prepared statements and pooling
  • Connecting securely to managed databases (e.g. Amazon RDS/Aurora) over SSL

Under The Hood

Architecture — MySQL2’s entry point (index.js) wires up factory functions (createConnection, createPool, createPoolCluster, createServer) over a core Connection class in lib/connection.js. Each connection owns a PacketParser (lib/packet_parser.js) that incrementally reads bytes off the socket and dispatches complete MySQL protocol packets to a queue of command objects in lib/commands/ (handshake, query, execute, prepare, ping, change_user, binlog_dump, etc.), each modeled as a small state machine extending command.js. Packet encode/decode lives in lib/packets/, result parsing and caching in lib/parsers/, and pooling logic in lib/pool.js / lib/pool_cluster.js, with a parallel promise API layer in lib/promise/ and promise.js.

Tech Stack — The library is authored in JavaScript (with TypeScript typings under typings/) targeting Node.js >= 8 and CommonJS. Runtime dependencies are deliberately small and pure-JS: denque for fast queues, iconv-lite for encodings, long for 64-bit integers, lru.min for statement/parser caches, named-placeholders and sql-escaper for query building/escaping, generate-function for compiled parsers, and aws-ssl-profiles for managed-DB TLS. Build/test tooling includes Rollup, ESLint, Prettier, TypeScript, the Poku test runner, and c8 for coverage.

Code Quality — The project is mature and well-tested, with test/unit and test/integration suites plus Dockerized runs against real MySQL, a test/tsc-build typecheck harness, and CI with Codecov coverage reporting. Cross-runtime tests target Node.js, Bun, and Deno. Code is linted and Prettier-formatted, and the codebase is organized into clearly separated protocol, command, packet, and pooling modules.

API Design — The public API mirrors the widely-known mysqljs/mysql surface, easing migration, and layers a clean promise wrapper on top (require('mysql2/promise')). Common tasks — a first query, prepared statements via execute, and connection pools — require little boilerplate, and extensive multi-language documentation, examples, and an FAQ back up the ergonomics.

Used by 41 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
Rust
67%
MIT

Bun

Developer Tools

95,452

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
66
Dependency
Built with
Rust67%
C++19%
Updated today
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,041

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
65
Dependency
Built with
JavaScript99%
Updated 6 days ago
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,221

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
91
Repo Health
9
Technical
72
Dependency
Built with
Go79%
Shell20%
Updated today
JavaScript
52%
MIT

evidence

Analytics · Data Engineering

6,861

Turn SQL queries and markdown files into polished, interactive data apps and business intelligence reports — no drag-and-drop, no GUI, just code.

View details
65
Repo Health
79
Technical
65
Dependency
Built with
JavaScript52%
Svelte40%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search