# mariadb

> fast mariadb or mysql connector.

Latest version **3.5.4** (published 2026-09-01) · LGPL-2.1-or-later license · 0 weekly downloads

## Install

```sh
npm install mariadb
pnpm add mariadb
yarn add mariadb
bun add mariadb
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.5.4 |
| Published | 2026-09-01 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | LGPL-2.1-or-later |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >= 20.0.0 |
| Dependencies | 5 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 412 |
| Author | Diego Dupin |
| Maintainers | rusher, npm_mariadb, dbart |
| Keywords | mariadb, mysql, client, driver, connector |

## Links

- npm: https://www.npmjs.com/package/mariadb
- Repository: https://github.com/mariadb-corporation/mariadb-connector-nodejs
- Homepage: https://github.com/mariadb-corporation/mariadb-connector-nodejs#readme
- Issues: https://jira.mariadb.org/projects/CONJS/
- npm.io page: https://npm.io/package/mariadb

## Dependencies (5)

- [denque](https://npm.io/package/denque.md) ^2.1.0
- [lru-cache](https://npm.io/package/lru-cache.md) ^11.5.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.7.2
- [@types/node](https://npm.io/package/@types/node.md) >=20
- [@types/geojson](https://npm.io/package/@types/geojson.md) ^7946.0.16

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.5.4 (latest) — 2026-09-01
- 3.3.4 (maintenance-3.3) — 2026-09-01
- 3.4.7 (maintenance-3.4) — 2026-09-01
- 3.2.5 (maintenance-3.2) — 2026-09-01
- 3.0.0-rc.0 (rc) — 2021-10-20
- 3.0.0-beta (beta) — 2021-06-21
- 3.5.3 — 2026-06-09
- 3.5.2 — 2026-03-06
- 3.5.1 — 2026-02-18
- 3.4.5 — 2025-07-23
- 3.4.4 — 2025-07-03
- 3.4.3 — 2025-07-02
- 3.4.2 — 2025-04-25
- 3.4.1 — 2025-04-02
- 3.4.0 — 2024-10-24
- … 43 more at https://npm.io/package/mariadb/versions

## README

<p style="text-align: center;">
  <a href="https://mariadb.com/">
    <img src="https://mariadb.com/wp-content/uploads/2019/11/mariadb-horizontal-blue.svg"/>
  </a>
</p>

# MariaDB Node.js connector

[![npm package][npm-image]][npm-url] 
[![CI Tests][ci-image]][ci-url]
[![License (LGPL version 2.1)][licence-image]][licence-url]
[![codecov][codecov-image]][codecov-url]

**Non-blocking MariaDB and MySQL client for Node.js.**

MariaDB and MySQL client, 100% JavaScript, with TypeScript definition, with the Promise API, distributed under the LGPL license version 2.1 or later (LGPL-2.1-or-later)

Since 3.5.3, this requires Node.js 20 or later.

## Documentation

See [promise documentation](https://mariadb.com/docs/connectors/mariadb-connector-nodejs/connector-nodejs-promise-api) for a detailed API.

[Callback documentation](https://mariadb.com/docs/connectors/mariadb-connector-nodejs/connector-nodejs-callback-api) describes the callback wrapper for compatibility with existing drivers.

See [dedicated part](https://mariadb.com/docs/connectors/mariadb-connector-nodejs/connector-nodejs-promise-api#migrating-from-2.x-or-mysql-mysql2-to-3.x) for migration from mysql/mysql2 or from the 2.x version.


## Why a specific MariaDB Client?

While there are existing MySQL clients that work with MariaDB, (such as the [`mysql`](https://www.npmjs.com/package/mysql) and [`mysql2`](https://www.npmjs.com/package/mysql2) clients), the MariaDB Node.js Connector offers new functionality, like [Insert Streaming](#insert-streaming), [Pipelining](#pipelining), [ed25519 plugin authentication](https://mariadb.org/history-of-mysql-mariadb-authentication-protocols/) while making no compromises on performance.

The Connector is production grade quality, with multiple features:
* [zero configuration ssl](https://mariadb.org/mission-impossible-zero-configuration-ssl/)
* superfast batching
* fast pool
* easy debugging, trace pointing to code line on error
* allows data streaming without high memory consumption
* pipelining
* metadata skipping (for MariaDB server only)
* sql file import
* ...

see some of those features:

### Insert Streaming

Using a Readable stream in your application, you can stream `INSERT` statements to MariaDB through the Connector.

```javascript
    
    https.get('https://someContent', readableStream => {
        //readableStream implement Readable, driver will stream data to database 
        connection.query("INSERT INTO myTable VALUE (?)", [readableStream]);
    });
```

### Pipelining

With Pipelining, the Connector sends commands without waiting for server results, preserving order.  For instance, consider the use of executing two `INSERT`  statements.

<p style="text-align: center;">
    <img src="./documentation/misc/pip.png" alt="pipelining example"/>
</p>

The Connector doesn't wait for query results before sending the next `INSERT` statement. Instead, it sends queries one after the other, avoiding much of the network latency.

For more information, see the [Pipelining](https://mariadb.com/docs/connectors/mariadb-connector-nodejs/connector-nodejs-pipelining) documentation.

### Bulk insert

Some use cases require a large amount of data to be inserted into a database table. By using batch processing, these queries can be sent to the database in one call, thus improving performance.

For more information, see the [Batch](https://mariadb.com/docs/connectors/mariadb-connector-nodejs/connector-nodejs-batch-api) documentation.


## Benchmarks

MariaDB provides benchmarks comparing the Connector with other Node.js MariaDB/MySQL clients, including [`mysql`](https://www.npmjs.com/package/mysql) (via [`promise-mysql`](https://www.npmjs.com/package/promise-mysql)) and [`mysql2`](https://www.npmjs.com/package/mysql2).

See the [Benchmarks](./documentation/benchmarks.md) page for the full list of results and how to run them.

#### query

```
select 100 int
          mariadb : 10,266.8 ops/s ± 0.2%  (  +87.6% )
            mysql :  5,472.4 ops/s ± 0.2%
           mysql2 :  4,783.5 ops/s ± 0.3%  (  -12.6% )
```
![select 100 int benchmark results](https://quickchart.io/chart/render/zm-ef74089a-be91-49f1-b5a0-5b9ac5752435?data1=5472&data2=4784&data3=10267)

#### execute

```
select 100 int - BINARY
          mariadb : 10,605.8 ops/s ± 0.2%  ( +124.1% )
           mysql2 :  4,731.8 ops/s ± 0.3%
```
![select 100 int - BINARY benchmark results](https://quickchart.io/chart/render/zm-36b213f4-8efe-4943-8f94-82edf94fce83?data1=4732&data2=10606)


## Quick Start

The MariaDB Connector is available through the Node.js repositories. You can install it using npm :

```
$ npm install mariadb
```
example:
```js
const mariadb = require('mariadb');
const pool = mariadb.createPool({host: process.env.DB_HOST, user: process.env.DB_USER, connectionLimit: 5});

async function asyncFunction() {
  let conn;
  try {

	conn = await pool.getConnection();
	const rows = await conn.query("SELECT 1 as val");
	// rows: [ {val: 1}, meta: ... ]

	const res = await conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
	// res: { affectedRows: 1, insertId: 1, warningStatus: 0 }

  } finally {
	if (conn) conn.release(); //release to pool
  }
}
```
## Contributors

A big thanks to all contributors

<a href="https://github.com/mariadb-corporation/mariadb-connector-nodejs/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=mariadb-corporation/mariadb-connector-nodejs&max=180&columns=15"  alt="contributors list"/>
</a>

## Contributing

If you would like to contribute to the MariaDB Node.js Connector, please follow the instructions given in the [contributing guide.](/CONTRIBUTING.md)

To file an issue or follow the development, see [JIRA](https://jira.mariadb.org/projects/CONJS/issues/).


[ci-image]:https://github.com/mariadb-corporation/mariadb-connector-nodejs/actions/workflows/ci.yml/badge.svg?branch=master
[ci-url]:https://github.com/mariadb-corporation/mariadb-connector-nodejs/actions/workflows/ci.yml
[npm-image]:https://img.shields.io/npm/v/mariadb.svg
[npm-url]:http://npmjs.org/package/mariadb
[licence-image]:https://img.shields.io/badge/license-GNU%20LGPL%20version%202.1-green.svg?style=flat-square
[licence-url]:http://opensource.org/licenses/LGPL-2.1
[codecov-image]:https://codecov.io/gh/mariadb-corporation/mariadb-connector-nodejs/branch/master/graph/badge.svg
[codecov-url]:https://codecov.io/gh/mariadb-corporation/mariadb-connector-nodejs

---
_Source: https://npm.io/package/mariadb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
