MariaDB Connector/Node.js when Connecting to Local Databases

MariaDB Connector/Node.js is a native Javascript driver.

The required files can be downloaded from:
The source code is available on GitHub:
MariaDB Connector/Node.js on npm, the package manager for JavaScript:

Installing the Driver The driver can be installed using npm: npm install mariadb

See promise documentation for detailed API.
Callback documentation describe the callback wrapper for compatibility with existing drivers.

Connecting to Local Databases:

When working with a local database (that is, cases where MariaDB and your Node.js application run on the same host), you can connect to MariaDB through the Unix socket or Windows named pipe for better performance, rather than using the TCP/IP layer.

In order to set this up, you need to assign the connection a socketPath value. When this is done, the Connector ignores the host and port options.

The specific socket path you need to set is defined by the socket server system variable. If you don't know it off hand, you can retrieve it from the server.

Note: need config in "my.ini":

Example: C:\Program Files\MariaDB 10.5\data\my.ini:
datadir=C:/Program Files/MariaDB 10.5/data
plugin-dir=C:/Program Files/MariaDB 10.5/lib/plugin

Creat Pool Connect:

const mariadb = require('mariadb');
const pool= mariadb.createPool({
    socketPath: '\\\\.\\pipe\\MySQL',// '/var/lib/mysql/mysql.sock' on Unix-like operating systems
    user: 'root',
    password: 'pass12345',
    // connectionLimit: 5