{"id":43261,"library":"mysql-connection-pool-manager","title":"MySQL Connection Pool Manager","description":"A production-level Node.js wrapper for mysqljs/mysql that provides intelligent management and load balancing of MySQL connection pools. It automatically scales connections based on load, closes idle connections to prevent exhaustion of server max_connections, and supports instancing for custom clustering. Current stable version is 1.5.9, last updated in 2019. It requires mysql@>=2.14.0 <3.0.0 as a peer dependency and supports Node.js 8+. Key differentiators: automatic idle connection cleanup, dynamic configuration changes, and exported internal functions for custom scripts.","status":"maintenance","version":"1.5.9","language":"javascript","source_language":"en","source_url":"https://github.com/daviemakz/mysql-connection-pool-manager","tags":["javascript","mysql","connection","pool","manager"],"install":[{"cmd":"npm install mysql-connection-pool-manager","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-connection-pool-manager","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-connection-pool-manager","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the actual MySQL driver used internally for connection pooling and queries.","package":"mysql","optional":false}],"imports":[{"note":"CommonJS require works for Node.js. ESM import may require bundler or Node.js >= 16 with { \"type\": \"module\" }.","wrong":"const MySQLConnectionPoolManager = require('mysql-connection-pool-manager')","symbol":"default","correct":"import MySQLConnectionPoolManager from 'mysql-connection-pool-manager'"},{"note":"The package exports a single class named MySQLConnectionPoolManager. Named destructuring is valid but default import is more common.","wrong":"const PoolManager = require('mysql-connection-pool-manager').PoolManager","symbol":"MySQLConnectionPoolManager","correct":"const { MySQLConnectionPoolManager } = require('mysql-connection-pool-manager')"},{"note":"getPool is an instance method, not a static or named export. Must call on an instance.","wrong":"import { getPool } from 'mysql-connection-pool-manager'","symbol":"getPool","correct":"import MySQLConnectionPoolManager from 'mysql-connection-pool-manager'; const pool = manager.getPool()"}],"quickstart":{"code":"import MySQLConnectionPoolManager from 'mysql-connection-pool-manager';\n\nconst poolManager = new MySQLConnectionPoolManager({\n  poolConfig: {\n    connectionLimit: 100,\n    host: 'localhost',\n    port: 3306,\n    user: 'root',\n    password: process.env.MYSQL_PASSWORD ?? '',\n    database: 'test'\n  },\n  poolManagerConfig: {\n    maxWaitForConnection: 10000,\n    maxKeepAlive: 30000,\n    minKeepAlive: 10000,\n    maxQueue: 50,\n    trace: false\n  }\n});\n\npoolManager.getConnection((err, connection) => {\n  if (err) throw err;\n  connection.query('SELECT 1', (err, results) => {\n    if (err) throw err;\n    console.log(results);\n    poolManager.releaseConnection(connection);\n  });\n});","lang":"typescript","description":"Demonstrates creating a MySQL connection pool manager, getting a connection, executing a query, and releasing the connection."},"warnings":[{"fix":"Update to pass poolConfig and poolManagerConfig as separate properties.","message":"Version 1.0.0 changed the constructor signature; poolConfig and poolManagerConfig are now required objects.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Use `getConnection()` and `releaseConnection()` instead of manipulating the pool directly.","message":"The method `getPool()` returns the internal mysql pool; direct access to the pool is discouraged in favor of using poolManager methods.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install mysql@2.x (e.g., npm install mysql@2.18.1).","message":"The peer dependency version `mysql@>=2.14.0 <3.0.0` is strictly enforced. Using mysql 3.x will cause runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set a higher `maxQueue` value in poolManagerConfig if you expect many concurrent requests.","message":"If `maxQueue` is exceeded, new connection requests will be rejected immediately. Default is 50.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `trace: false` to suppress deprecation warnings; remove in future.","message":"The property `poolManagerConfig.trace` is deprecated and may be removed in future versions.","severity":"deprecated","affected_versions":">=1.5.0"}],"env_vars":null,"search_vec":"'1.5.9':51 '2.14.0':59 '2019':55 '3.0.0':60 '8':68 'automat':25,71 'balanc':19 'base':28 'chang':77 'cleanup':74 'close':31 'cluster':46 'configur':76 'connect':2,22,27,33,40,73,87 'current':47 'custom':45,83 'depend':64 'differenti':70 'dynam':75 'exhaust':36 'export':79 'function':81 'idl':32,72 'instanc':43 'intellig':15 'intern':80 'javascript':85 'key':69 'last':52 'level':8 'load':18,30 'manag':4,16,89 'max':39 'mysql':1,21,58,86 'mysqljs/mysql':12 'node.js':9,67 'peer':63 'pool':3,23,88 'prevent':35 'product':7 'production-level':6 'provid':14 'requir':57 'scale':26 'script':84 'server':38 'stabl':48 'support':42,66 'updat':53 'version':49 'wrapper':10","created_at":"2026-06-05T16:58:57.457684+00:00","updated_at":"2026-06-05T16:58:57.457684+00:00","problems":[{"fix":"Run `npm install mysql-connection-pool-manager` and ensure no typo in require/import.","cause":"Package not installed or typo in import/require path.","error":"Cannot find module 'mysql-connection-pool-manager'"},{"fix":"Ensure each route handler sends only one response; avoid calling next() after res.send()/res.json()","cause":"Multiple responses sent in Express route handler, often due to calling next() after sending a response.","error":"Error: Can't set headers after they are sent."},{"fix":"Use correct import: `const PoolManager = require('mysql-connection-pool-manager'); const poolManager = new PoolManager(...)`","cause":"poolManager is not an instance of MySQLConnectionPoolManager; likely imported incorrectly.","error":"TypeError: poolManager.getConnection is not a function"}],"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/daviemakz/mysql-connection-pool-manager#readme","github":"https://github.com/daviemakz/mysql-connection-pool-manager","docs":null,"changelog":null,"pypi":null,"npm":"mysql-connection-pool-manager","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}}