{"id":43259,"library":"mysql-clusterfarm","title":"mysql-clusterfarm - MySQL Cluster Farm Driver","description":"A Node.js MySQL driver branched from mysqljs/mysql (v2.7.9) to add clustering capabilities, allowing connection pooling across replicated masters and slaves with automatic failover and deadlock handling. It is pure JavaScript, MIT licensed, and targets Node >= 0.6. Unlike the original mysql package, it introduces PoolClusterFarm for multi-master and multi-slave replication management, scaling from 1 master to many. However, it is unmaintained since 2017 (last commit) and relies on outdated dependencies.","status":"deprecated","version":"2.7.9","language":"javascript","source_language":"en","source_url":"https://github.com/happilymarrieddad/mysql-clusterfarm","tags":["javascript"],"install":[{"cmd":"npm install mysql-clusterfarm","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-clusterfarm","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-clusterfarm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Fork of the mysql package; uses internal mysql protocol logic","package":"mysql","optional":false}],"imports":[{"note":"CommonJS only; no ESM support. Do not confuse with the 'mysql' package.","wrong":"const mysql = require('mysql')","symbol":"mysql","correct":"import mysql from 'mysql-clusterfarm'"},{"note":"Call as a method of the default export; factory pattern.","wrong":"const poolClusterFarm = require('mysql-clusterfarm').createPoolClusterFarm()","symbol":"poolClusterFarm","correct":"const poolClusterFarm = mysql.createPoolClusterFarm()"},{"note":"Same API as mysql package; createPool returns a Pool instance.","wrong":"const pool = new mysql.Pool()","symbol":"createPool","correct":"const pool = mysql.createPool({...})"}],"quickstart":{"code":"const mysql = require('mysql-clusterfarm');\nconst poolClusterFarm = mysql.createPoolClusterFarm();\n\n// Add masters and slaves\npoolClusterFarm.addMaster('MASTER0', {\n  host: process.env.MYSQL_HOST ?? 'localhost',\n  user: process.env.MYSQL_USER ?? 'root',\n  password: process.env.MYSQL_PASS ?? ''\n});\npoolClusterFarm.addSlave('SLAVE0', 'MASTER0', {\n  host: process.env.MYSQL_SLAVE_HOST ?? 'localhost',\n  user: process.env.MYSQL_USER ?? 'root',\n  password: process.env.MYSQL_PASS ?? ''\n});\n\n// Get a connection from the cluster\npoolClusterFarm.getConnection((err, connection) => {\n  if (err) throw err;\n  connection.query('SELECT 1 + 1 AS solution', (err, results) => {\n    connection.release();\n    if (err) throw err;\n    console.log(results[0].solution);\n  });\n});","language":"javascript","description":"Demonstrates setting up a PoolClusterFarm with a master and slave, then executing a query."},"warnings":[{"fix":"Always use 'mysql-clusterfarm' in require/import statements, not 'mysql'.","message":"The package is a fork of mysqljs/mysql. Do not mix imports between the two; they are separate.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using mysql2 with connection pooling or a dedicated clustering library like 'mysql-replication'.","message":"Package is unmaintained since 2017. No security updates or Node.js version compatibility patches.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Review deadlock handling options in PoolClusterFarm and test under load.","message":"Deadlock handling can cause unexpected transaction rollbacks if not properly configured.","severity":"gotcha","affected_versions":">=2.7.0"},{"fix":"Always provide a unique name as first argument to addMaster/addSlave.","message":"Breaking change: The poolClusterFarm API changed from earlier versions; addMaster/addSlave now require explicit names.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'0.6':43 '1':64 '2017':73 'across':23 'add':17 'allow':20 'automat':29 'branch':12 'capabl':19 'cluster':5,18 'clusterfarm':3 'commit':75 'connect':21 'deadlock':32 'depend':80 'driver':7,11 'failov':30 'farm':6 'handl':33 'howev':68 'introduc':50 'javascript':37,81 'last':74 'licens':39 'manag':61 'mani':67 'master':25,55,65 'mit':38 'multi':54,58 'multi-mast':53 'multi-slav':57 'mysql':2,4,10,47 'mysql-clusterfarm':1 'mysqljs/mysql':14 'node':42 'node.js':9 'origin':46 'outdat':79 'packag':48 'pool':22 'poolclusterfarm':51 'pure':36 'reli':77 'replic':24,60 'scale':62 'sinc':72 'slave':27,59 'target':41 'unlik':44 'unmaintain':71 'v2.7.9':15","created_at":"2026-06-05T16:58:56.530683+00:00","updated_at":"2026-06-05T16:58:56.530683+00:00","problems":[{"fix":"npm install mysql-clusterfarm (may need to install mysql separately: npm install mysql)","cause":"Missing mysql package dependency; mysql-clusterfarm expects mysql as a peer dependency or internal module.","error":"Error: Cannot find module 'mysql'"},{"fix":"const mysql = require('mysql-clusterfarm'); const poolClusterFarm = mysql.createPoolClusterFarm();","cause":"Importing the module incorrectly, or using an older API where getConnection is not available.","error":"TypeError: poolClusterFarm.getConnection is not a function"},{"fix":"Double-check user, password, and host in addMaster/addSlave options.","cause":"Invalid credentials or missing privileges on MySQL server.","error":"ER_ACCESS_DENIED_ERROR: Access denied for user"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/happilymarrieddad/mysql-clusterfarm#readme","github":"https://github.com/happilymarrieddad/mysql-clusterfarm","docs":null,"changelog":null,"pypi":null,"npm":"mysql-clusterfarm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}