# sidorares/node-mysql2

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/sidorares-node-mysql2).**

4,369 stars · 670 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/sidorares/node-mysql2
- Homepage: https://sidorares.github.io/node-mysql2/
- awesome-repositories: https://awesome-repositories.com/repository/sidorares-node-mysql2.md

## Description

This project is a MySQL database driver for Node.js that establishes network connections and executes SQL queries using a native communication protocol. It functions as an asynchronous SQL client, providing a promise-based query interface and support for async/await patterns to manage non-blocking database operations.

The library includes a full MySQL protocol implementation, serving as a toolkit for building custom database servers, proxies, or clients. It also operates as a connection pool manager and an injection prevention tool, utilizing prepared statements and parameterized queries to secure database interactions.

The project covers a broad range of database integration capabilities, including atomic transaction coordination, binary log streaming, and tabular data streaming for bulk imports. It manages resource lifecycles through automated connection cleanup and provides various authentication mechanisms, such as password hash authentication and secure handshake negotiation.

Connectivity is further supported via SSL encryption, network traffic compression, and the ability to route traffic through custom duplex stream transports.

## Tags

### Data & Databases

- [MySQL Connectors](https://awesome-repositories.com/f/data-databases/database-connectivity/mysql-connectors.md) — Provides a specialized Node.js driver for establishing secure network connections and executing queries on MySQL databases. ([source](https://github.com/sidorares/node-mysql2/blob/master/package-lock.json))
- [MySQL Integrations](https://awesome-repositories.com/f/data-databases/mysql-integrations.md) — Establishes network connections to a MySQL database to execute queries and manage data storage in Node.js.
- [Node.js Connectors](https://awesome-repositories.com/f/data-databases/mysql-integrations/node-js-connectors.md) — Implements a native MySQL database driver specifically for the Node.js runtime environment.
- [Connection Pools](https://awesome-repositories.com/f/data-databases/connection-pools.md) — Manages a cache of reusable MySQL connections to reduce latency and improve application performance.
- [Protocol Packet Parsers](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/stream-processing-systems/packet-based-stream-processors/protocol-packet-parsers.md) — Implements the MySQL wire protocol to decode raw binary network streams into structured data packets.
- [Connection Pool Managers](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/connection-transaction-management/connection-pool-managers.md) — Manages groups of database connections with support for cluster routing and graceful shutdown procedures. ([source](https://github.com/sidorares/node-mysql2/blob/master/Changelog.md))
- [Database Query Execution](https://awesome-repositories.com/f/data-databases/database-query-execution.md) — Executes SQL queries and retrieves data using the native MySQL communication protocol. ([source](https://github.com/sidorares/node-mysql2/blob/master/deno.json))
- [Promise-Wrapped Querying](https://awesome-repositories.com/f/data-databases/database-query-execution/promise-wrapped-querying.md) — Provides a promise-wrapped interface for database queries to enable asynchronous control flow using async/await.
- [MySQL Connection Poolers](https://awesome-repositories.com/f/data-databases/mysql-connection-poolers.md) — Provides a dedicated manager for reusable MySQL database connections to optimize session establishment and reduce latency.
- [Prepared Statements](https://awesome-repositories.com/f/data-databases/prepared-statements.md) — Supports parameterized queries to increase execution speed and protect the database from injection attacks. ([source](https://github.com/sidorares/node-mysql2/blob/master/package.json))
- [Promise-Based SQL Clients](https://awesome-repositories.com/f/data-databases/sql-database-connectors/asynchronous-sql-toolkits/promise-based-sql-clients.md) — Provides a database interface with promise-based query execution and async/await support.
- [SQL Query Execution](https://awesome-repositories.com/f/data-databases/sql-query-execution.md) — Sends SQL statements to a database and processes returned results using asynchronous JavaScript patterns.
- [Binary Log Streaming Tools](https://awesome-repositories.com/f/data-databases/binary-log-streaming-tools.md) — Interfaces with the binary log protocol to replicate data changes and track database events in real-time. ([source](https://sidorares.github.io/node-mysql2/docs/documentation))
- [Atomic Transaction Coordinators](https://awesome-repositories.com/f/data-databases/concurrent-write-optimizations/atomic-transaction-coordinators.md) — Coordinates sequences of operations through start, commit, and rollback commands to ensure atomic changes. ([source](https://github.com/sidorares/node-mysql2/blob/master/promise.d.ts))
- [Read-Write Splitting](https://awesome-repositories.com/f/data-databases/high-concurrency-database-access/connection-pooling/read-write-splitting.md) — Coordinates multiple connection pools across different servers to implement load balancing and read/write splitting. ([source](https://sidorares.github.io/node-mysql2/docs))
- [MySQL Clustering Systems](https://awesome-repositories.com/f/data-databases/mysql-clustering-systems.md) — Distributes database workloads across multiple servers to implement load balancing and read-write splitting.
- [Query Execution Engines](https://awesome-repositories.com/f/data-databases/query-execution-engines.md) — Processes database queries and converts returned results into specific data types for application use. ([source](https://github.com/sidorares/node-mysql2/blob/master/Changelog.md))
- [SQL Placeholder Bindings](https://awesome-repositories.com/f/data-databases/query-translators/placeholder-rebinders/sql-placeholder-bindings.md) — Maps query parameters to object keys and converts them into positional placeholders for secure execution. ([source](https://sidorares.github.io/node-mysql2/docs/documentation/extras))
- [Disposable Resource Management](https://awesome-repositories.com/f/data-databases/resource-management/resource-lifecycle-managers/disposable-resource-management.md) — Uses explicit disposal symbols to automatically release network sockets and clear memory when connections go out of scope.
- [Scope-Based Resource Cleanup](https://awesome-repositories.com/f/data-databases/resource-management/resource-teardown/scope-based-resource-cleanup.md) — Automatically releases database connections and pools when they go out of scope using explicit resource management. ([source](https://sidorares.github.io/node-mysql2/docs/documentation/promise-wrapper))
- [SQL Injection Prevention Tools](https://awesome-repositories.com/f/data-databases/sql-injection-prevention-tools.md) — Prevents SQL injection attacks through the use of prepared statements and parameterized queries.
- [Tabular Data Import](https://awesome-repositories.com/f/data-databases/tabular-data-import.md) — Streams local tabular data into the database using a readable stream factory for efficient bulk imports. ([source](https://sidorares.github.io/node-mysql2/docs/documentation/extras))

### Networking & Communication

- [Connection Pooling](https://awesome-repositories.com/f/networking-communication/connection-pooling.md) — Reduces latency and overhead by reusing existing network connections for multiple database requests. ([source](https://sidorares.github.io/node-mysql2/zh-CN/docs))
- [MySQL Protocol Implementations](https://awesome-repositories.com/f/networking-communication/network-protocol-implementations/mysql-protocol-implementations.md) — Provides a full implementation of the MySQL network protocol for building custom proxies or servers. ([source](https://sidorares.github.io/node-mysql2/docs/examples))
- [Connection Lifecycle Managers](https://awesome-repositories.com/f/networking-communication/connection-lifecycle-managers.md) — Tracks the state of active network sockets and uses disposal symbols to release system resources. ([source](https://github.com/sidorares/node-mysql2/blob/master/Changelog.md))
- [Pool Clustering](https://awesome-repositories.com/f/networking-communication/database-connection-pooling/pool-clustering.md) — Supports grouping multiple independent connection pools to distribute queries across different database nodes for load balancing.
- [Database Session Management](https://awesome-repositories.com/f/networking-communication/database-session-management.md) — Manages the establishment, termination, and resetting of individual sessions with the database server. ([source](https://github.com/sidorares/node-mysql2/blob/master/promise.d.ts))
- [Protocol Negotiation](https://awesome-repositories.com/f/networking-communication/http-2-support/protocol-negotiation.md) — Exchanges initialization packets with clients to negotiate protocol versions and feature flags. ([source](https://sidorares.github.io/node-mysql2/docs/documentation/mysql-server))
- [Server Instance Listeners](https://awesome-repositories.com/f/networking-communication/server-instance-listeners.md) — Allows starting a server instance that listens on a port or unix socket to accept incoming database connections. ([source](https://sidorares.github.io/node-mysql2/docs/documentation/mysql-server))

### Programming Languages & Runtimes

- [Async-Await Flow Control](https://awesome-repositories.com/f/programming-languages-runtimes/async-await-flow-control.md) — Implements async and await syntax to simplify the logic of asynchronous database control flows. ([source](https://sidorares.github.io/node-mysql2/pt-BR/docs))

### Security & Cryptography

- [Query Parameterization](https://awesome-repositories.com/f/security-cryptography/query-parameterization.md) — Implements prepared statements to separate query logic from data, preventing SQL injection attacks.
- [SQL Injection Prevention](https://awesome-repositories.com/f/security-cryptography/sql-injection-prevention.md) — Secures database interactions against malicious input using prepared statements and parameterized queries.
- [Handshake Protocols](https://awesome-repositories.com/f/security-cryptography/authenticated-encryption/handshake-protocols.md) — Performs secure handshakes using the server's preferred authentication method and configurable encryption contexts. ([source](https://github.com/sidorares/node-mysql2/blob/master/Changelog.md))
- [Database Connection Encryption](https://awesome-repositories.com/f/security-cryptography/database-connection-encryption.md) — Secures the communication channel between the application and the database server using SSL/TLS encryption. ([source](https://sidorares.github.io/node-mysql2/docs/documentation))
- [Feature Flag Negotiations](https://awesome-repositories.com/f/security-cryptography/encryption-key-management/handshake-key-negotiations/feature-flag-negotiations.md) — Exchanges initialization packets and feature flags to determine authentication and compression settings during the handshake.
- [Input Sanitization](https://awesome-repositories.com/f/security-cryptography/input-sanitization.md) — Escapes values and identifiers to treat user input as data rather than executable code, preventing injection. ([source](https://github.com/sidorares/node-mysql2/blob/master/promise.d.ts))

### Software Engineering & Architecture

- [Database Protocol Proxies](https://awesome-repositories.com/f/software-engineering-architecture/database-protocol-proxies.md) — Enables building server interfaces and routing traffic through custom transports using the MySQL protocol.

### Part of an Awesome List

- [Databases](https://awesome-repositories.com/f/awesome-lists/data/databases.md) — Fast MySQL driver with compatibility.
