A Node.js driver aimed at speed, largely compatible with the popular mysql package API, with prepared statements, pooling, SSL, and binary protocol support.
Overview
MySQL2 is a Node.js client library for talking to MySQL servers. It continues the MySQL-Native protocol work with an API shaped to match the widely used Node MySQL driver so existing code can migrate with limited changes.
The driver supports prepared statements, extended charset and collation handling, promise wrappers, compression, SSL and authentication switching, custom streams, and connection pooling. It also supports the MySQL binary log protocol where relevant to consumers.
Installation requires no native bindings, with support for Linux, Mac OS, and Windows. TypeScript users can use @types/node for typings and separate documentation for TS examples.
The project coordinates with the broader mysqljs organization on shared pieces while maintaining its own protocol implementation and performance focus.
Key features
- mysqljs/mysql-compatible API surface
- Prepared statements
- Connection pooling
- SSL and auth switch support
- Compression option
- Promise wrapper
- Binary log protocol support
- Broad charset and collation support
Use cases
- Node.js services using MySQL
- Migrating from mysql package with familiar API
- Apps needing pooled database connections
- Workloads using prepared statements or SSL