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:
https://mariadb.com/downloads/connector
The source code is available on GitHub:
https://github.com/MariaDB/mariadb-connector-nodejs
MariaDB Connector/Node.js on npm, the package manager for JavaScript:
https://www.npmjs.com/package/mariadb



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.
SHOW VARIABLES LIKE 'socket';

Note: need config in "my.ini":

Example: C:\Program Files\MariaDB 10.5\data\my.ini:
[mysqld]
named-pipe
datadir=C:/Program Files/MariaDB 10.5/data
port=3306
innodb_buffer_pool_size=127M
character-set-server=utf8
[client]
port=3306
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
});

Comments

  1. CNC router kits can work with DSP, Mach3, Mach4, NcStudio, LNC, OSAI, LinuxCNC, PlanetCNC, Syntec, Siemens, FANUC, and more controllers based mostly on the business necessities. CNC routers can do reduction carving, rotary carving, flatbed slicing, 3D routing for wooden, aluminum, copper, brass, glass, plastic, acrylic, and foam. CNC machines are electrical discharge machines that integrate mechanical, electrical, hydraulic, pneumatic, and data applied sciences. It is Slippers a working machine with the advantages of|some great advantages of|the advantages of} excessive precision, excessive effectivity, excessive automation, and excessive flexibility, stability and dependable quality in mechanical manufacturing processes. CNC machining centers are used for elements processing of industries similar to navy, aerospace, energy, machinery manufacturing, ship manufacturing, and large-scale mould making. Being a subtractive technology, machining advanced geometries come at an elevated value.

    ReplyDelete

Post a Comment