MySQL2
A strong pick. 4th of 10 database drivers.
MySQL2 is the standard pure-JavaScript MySQL and MariaDB driver for Node.js, with promises, prepared statements, pooling and bundled TypeScript types. If you are starting a new project on MySQL today, it is the default pick. It is actively maintained. Its security record is mixed but well handled.
Best for: Node.js teams on MySQL, MariaDB or Aurora MySQL that want a mature driver, either used directly or under Drizzle, Kysely, Knex, TypeORM or Sequelize.
Scores
Overall8.0
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 7.5, likely 6.5 to 8.5
For MySQL in Node.js it is the default driver, and it is well maintained and growing. It ranks below node-postgres as a category pick because it serves a narrower database family. Its advisory record is also heavier, and the mariadb connector may be faster for MariaDB-specific workloads.
- npm downloadsLast4Weeks: Growing faster than the median
- orm.drizzle.team/docs/get-started-mysql: ORMs build on it
- advisories: Several serious but fixed advisories
GPT-6.2 Sol: 8.4, likely 7.3 to 9.3
MySQL2 is a strong choice for a new Node.js project using MySQL because it covers the core driver features, ships regular fixes, and has support from major tools and platforms. In this category the database choice determines the relevant peer, with node-postgres serving PostgreSQL and better-sqlite3 serving local SQLite. The reported TypeScript regression and gaps in release safeguards keep MySQL2 below the top tier.
- sidorares.github.io/node-mysql2/docs: Core MySQL driver features with worked examples
- github.releasesLastYear, peers: 37 releases in the past year and peers serving other databases
- developers.cloudflare.com/hyperdrive/examples/connect-to-mysql: Cloudflare recommends MySQL2 for Hyperdrive
- github.com/sidorares/node-mysql2/issues/4275: Open parameter typing regression
- scorecard: Weak workflow permissions and branch protection checks
Needed by many5.2
How many developers need a tool for this job?
Claude Opus 5.5: 5.5, likely 4.5 to 6.5
Most backend developers need a database driver, but this one only serves MySQL and MariaDB. MySQL is still one of the most widely used databases, while new JS projects lean more towards Postgres and SQLite. That makes it a large group, but not a majority.
- peers downloadsLast4Weeks: node-postgres has about 4x the downloads, which shows Postgres leads in JS
- Stack Overflow Developer Survey: MySQL ranks among the top databases, behind PostgreSQL
GPT-6.2 Sol: 4.8, likely 3.7 to 5.9
Database drivers serve a wide range of backend projects, and 35.1% of database respondents in the 2026 Stack Overflow survey reported using MySQL. MySQL2 serves MySQL-compatible databases and is built around Node.js APIs, with support on Cloudflare Workers through its compatibility layer. The survey covers multiple languages and leaves the share of JavaScript and TypeScript projects that need this driver uncertain.
- survey.stackoverflow.co/2026/technology/data: MySQL use was 35.1% among database respondents
- sidorares.github.io/node-mysql2/docs: MySQL driver built for Node.js
- developers.cloudflare.com/hyperdrive/examples/connect-to-mysql: Workers support through Node.js compatibility
Helps a lot8.0
How well does it do the job for those who need it?
Claude Opus 5.5: 7.5, likely 6.5 to 8.5
It is a full-featured driver: promise and callback APIs, prepared statements, pooling, SSL, compression, binlog and named placeholders, plus bundled types. AI agents write correct code for it easily because its API is widely known. Recent work fixed performance problems, but a vendor benchmark still shows the mariadb connector faster, and it lacks native batch and pipelining. The range is moderate because the speed gap comes from one vendor source and is outdated.
- mariadb.com/resources/blog/which-node-js-connector-is-best-to-use: Vendor benchmark shows mariadb faster, and mysql2 lacks batch and pipelining
- npm-compare.com/mysql,mysql2: Feature and performance comparison favouring mysql2 over mysql
- bluesky top post: One PR landed 10 performance fixes in 2026
- npm hasTypes: Types bundled
GPT-6.2 Sol: 8.5, likely 7.4 to 9.4
Version 3.24.6 covers routine MySQL work with pools, cached prepared statements, TLS, Promise and callback APIs, and bundled types. The quickstart gives coding agents examples to follow, though callers still supply row shapes and the parameter types reject some valid JSON objects. Fluxify measured faster concurrent reads with Bun SQL but kept MySQL2 for its connection setup hooks. That test leaves performance on current Node.js workloads less certain.
- sidorares.github.io/node-mysql2/docs: Pooling, TLS, prepared statements, and API examples
- sidorares.github.io/node-mysql2/docs/documentation/typescript-examples: Result shapes use caller-supplied types
- github.com/sidorares/node-mysql2/issues/4275: User reports a parameter typing regression
- github.com/sidorares/node-mysql2/blob/v3.24.6/typings/mysql/lib/protocol/sequences/Query.d.ts: Current release retains the reported parameter restriction
- github.com/Fluxify-rest/Fluxify/issues/573: Downstream benchmark and decision to keep MySQL2
- github.com/sidorares/node-mysql2/issues/702: User hit the server's prepared statement limit with a pool
Holds up over time8.1
Will it still be a good choice in two years?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
Activity is high: 536 commits and 37 releases in the last year, a push the day before the data was read, and 287 contributors. Version 3.x has kept its API stable for years. The project is led by its original author plus at least one very active co-maintainer, but it has no clear corporate funding. That gap keeps the score below 9.
- github commitsLastYear: 536 commits
- github releasesLastYear: 37 releases
- newreleases.io/project/npm/mysql2/release/3.20.0: 3.20 added TracingChannel support and a pool fix
- scorecard Maintained: Maintained check scores 10
GPT-6.2 Sol: 8.1, likely 6.9 to 9.1
MySQL2 recorded 536 commits and 37 releases in the past year, with more commits than any listed peer. The release history shows regular fixes within the 3.x line, although a parameter typing regression reported in April remains open. Public sponsorship is listed for one maintainer, and funding and release authority are unclear.
- github.commitsLastYear, github.releasesLastYear, peers: 536 commits and 37 releases, with the highest commit count among listed drivers
- github.com/sidorares/node-mysql2/releases: Recent fixes for pooling, timeouts, and protocol behavior
- github.com/sidorares/node-mysql2/issues/4275: April typing regression remains open
- github.com/sidorares/node-mysql2/blob/master/.github/FUNDING.yml: One GitHub Sponsors account is listed
Used widely7.5
How many use it, and is that growing?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
It has about 96M downloads per 4 weeks, up from 15M a year ago. That ratio of about 6.3 is above the 4.1 median, so it is gaining ground. It has 126,697 dependent repos and 4,001 dependent packages, second among SQL drivers after node-postgres. Many downloads come through ORMs and query builders, but those still reflect people choosing MySQL.
- npm downloadsLast4Weeks: 96.4M, against 15.4M a year before
- dependents: 126,697 repos and 4,001 packages
- medianDownloadsRatio: Its ratio of 6.3 beats the 4.1 median
GPT-6.2 Sol: 7.0, likely 5.9 to 8.0
Downloads rose 6.3-fold year over year, ahead of the 4.1-fold catalog median and behind node-postgres at 8.3-fold. The sampled 126,697 dependent repositories put MySQL2 below node-postgres and the MongoDB driver, and well above better-sqlite3 on this measure. Automated installs and use through ORMs make direct choices hard to isolate, and the single Bluesky post adds little evidence about momentum.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio: 96.4 million versus 15.4 million downloads in matching four-week windows
- dependents, peers: 126,697 sampled repositories and 4,001 npm packages depend on MySQL2
- bluesky.posts: One repository-linked post in 24 months
- sequelize.org/docs/v6/other-topics/dialect-specific-things: Some installs reflect a choice to use Sequelize with MySQL
Vouched for7.7
Who stands behind it being good?
Claude Opus 5.5: 7.0, likely 6.0 to 8.0
Major tools build on it: Drizzle ships a native mysql2 integration, and Cloudflare Hyperdrive documents it as the MySQL driver to use. Kysely, Knex, TypeORM and Sequelize also rely on it. It has little independent survey or benchmark coverage, and the one benchmark found comes from a competitor.
- orm.drizzle.team/docs/get-started-mysql: Drizzle supports mysql2 natively
- developers.cloudflare.com/hyperdrive/examples/connect-to-mysql: Cloudflare documents mysql2 for Hyperdrive
- hackerNews stories: No HN stories
GPT-6.2 Sol: 8.4, likely 7.4 to 9.3
Cloudflare recommends MySQL2 for Hyperdrive, and Sequelize, Kysely, and Drizzle build their MySQL support on it. Fluxify publicly documented keeping it after testing an alternative. That is direct evidence of downstream trust, while driver-specific satisfaction and independent benchmarks on current Node.js remain sparse.
- developers.cloudflare.com/hyperdrive/examples/connect-to-mysql: Cloudflare's recommended MySQL driver for Hyperdrive
- sequelize.org/docs/v6/other-topics/dialect-specific-things: Sequelize uses it as its MySQL connector
- kysely.dev/docs/getting-started?dialect=mysql: Kysely uses it for its built-in MySQL dialect
- orm.drizzle.team/docs/mysql/get-started-mysql: Drizzle recommends it and provides a native adapter
- github.com/Fluxify-rest/Fluxify/issues/573: Downstream project kept MySQL2 after benchmarking Bun SQL
Safe6.6
How safe is it to depend on?
Claude Opus 5.5: 6.0, likely 5.0 to 7.0
It has 7 advisories in total. These include two critical code-injection and RCE flaws in 2024, and two new ones in 2026: a credential leak through a cleartext auth downgrade, and a decompression-bomb DoS. All are fixed; the credential leak was fixed in 3.22.0 behind a new opt-in flag. The Scorecard is 6.5, with weak token-permissions, branch-protection and fuzzing checks. It pulls in 7 dependencies and is MIT licensed.
- advisories: 7 in total, 2 in the last 24 months, including critical RCEs in 2024
- advisories.gitlab.com/npm/mysql2/GHSA-3f6p-5ww8-9rcr: Cleartext credential leak fixed in 3.22.0
- scorecard: Score 6.5; Token-Permissions, Branch-Protection and Fuzzing score 0
- npm dependencies: 7 dependencies
GPT-6.2 Sol: 7.1, likely 5.9 to 8.1
The MIT-licensed package has seven direct dependencies, and its release workflow publishes to npm with provenance and a stored token. The current version includes fixes for both 2026 advisories, with patches available by public disclosure. Earlier critical issues also received patches. The 6.5 OpenSSF Scorecard shows strong code review and a security policy, with weak checks for token permissions, branch protection, dependency pinning, and fuzzing.
- npm.license, npm.dependencies: MIT licence and seven direct dependencies
- github.com/sidorares/node-mysql2/blob/v3.24.6/.github/workflows/release.yml: GitHub Actions publishes stable npm releases with provenance and a token
- github.com/advisories/GHSA-3f6p-5ww8-9rcr: Credential exposure fixed in 3.22.0
- github.com/advisories/GHSA-rgwj-5xj2-c3m3: Decompression denial of service fixed in 3.23.1
- github.com/sidorares/node-mysql2/releases/tag/v3.23.1: Decompression patch shipped July 19, the date of disclosure
- github.com/advisories/GHSA-4rch-2fh8-94vw: Earlier critical code injection fixed in 3.9.7
- scorecard: 6.5 overall, with zeros for token permissions, branch protection, and fuzzing
Good
- Mostly a drop-in, API-compatible replacement for the old mysql package, and it adds native promises and prepared statements.
- Most JS query builders and ORMs that support MySQL list it as their driver, including Drizzle, Kysely, Knex, TypeORM and Sequelize.
- Very active releases, about 37 in the last year, including recent performance work and fixes for Aurora failover.
- Pure JavaScript with no native build step, and TypeScript types are bundled.
Bad
- It has a history of serious advisories: two critical RCE flaws in 2024 and two new ones in 2026, all fixed.
- A benchmark by MariaDB, a vendor, shows the mariadb connector clearly faster on prepared statements and batch inserts.
- It only serves MySQL-family databases, and the backlog is large at about 400 open issues.
- Typing query results is loose: rows come back as generic RowDataPacket types unless you cast them.
The numbers
- npm downloads, 4 weeks
- 96M ×6.3 in a year
- GitHub stars
- 4.4k
- Commits, 12 months
- 536
- npm version
- 3.24.6 Oct 2026
- Versions, 12 months
- 37
- Advisories, 24 months
- 2 of 7 ever
- OpenSSF Scorecard
- 6.5 out of 10, Nov 2026
- Licence
- MIT
Read on 21 November 2026 from GitHub (sidorares/node-mysql2), npm (mysql2), OSV and the OpenSSF Scorecard.
Database drivers
- 8.7node-postgres
- 8.2MongoDB driver
- 8.1better-sqlite3
- 8.0MySQL2
- 7.6PGlite
- 7.5Postgres.js
- 7.4DuckDB Node Neo
- 7.1Neon serverless driver
- 5.9libSQL client
- 1.9node-sqlite3