{"id":43479,"library":"nodejs-mysql","title":"nodejs-mysql","description":"A Promise-based wrapper around the mysql driver for Node.js. Version 0.1.3, last published in 2017. Provides a simple API for MySQL operations including querying, inserts, updates, deletes, and transactions. Unlike raw mysql package, it returns Promises and manages connection pooling. Development is sporadic with no recent releases.","status":"deprecated","version":"0.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/alsey/nodejs-mysql","tags":["javascript","mysql","promise"],"install":[{"cmd":"npm install nodejs-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add nodejs-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add nodejs-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core MySQL driver that nodejs-mysql wraps","package":"mysql","optional":false}],"imports":[{"note":"CommonJS users must use require('nodejs-mysql').default","wrong":"const mysql = require('nodejs-mysql')","symbol":"default","correct":"import mysql from 'nodejs-mysql'"},{"note":"In CommonJS, default export is under .default","wrong":"const mysql = require('nodejs-mysql')","symbol":"default","correct":"const mysql = require('nodejs-mysql').default"},{"note":"getInstance is the main entry to create a database instance","wrong":"mysql.getInstance(config)","symbol":"mysql.getInstance","correct":"const db = mysql.getInstance(config)"}],"quickstart":{"code":"import mysql from 'nodejs-mysql';\n\nconst config = {\n  host: 'localhost',\n  port: 3306,\n  user: 'root',\n  password: 'password',\n  database: 'test'\n};\n\nconst db = mysql.getInstance(config);\n\ndb.exec('SELECT 1 + 1 AS solution')\n  .then(rows => {\n    console.log('The solution is:', rows[0].solution);\n  })\n  .catch(err => {\n    console.error('Error executing query:', err);\n  });","lang":"javascript","description":"Shows how to create a database instance and execute a simple SELECT query with promises."},"warnings":[{"fix":"Use `const mysql = require('nodejs-mysql').default;`","message":"Importing with `require('nodejs-mysql')` returns an object with a `default` property. You must use `require('nodejs-mysql').default`.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Migrate to mysql2 and use its built-in promise support: `import mysql from 'mysql2/promise';`","message":"Package has not been updated since 2017 and uses an outdated version of the mysql driver. Consider using mysql2 with direct promises.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure config is either a single object or a non-empty array of objects.","message":"Config must be an object for single connection or an array of objects for connection pool. Passing an empty array will cause errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.3':16 '2017':20 'api':24 'around':9 'base':7 'connect':44 'delet':32 'develop':46 'driver':12 'includ':28 'insert':30 'javascript':53 'last':17 'manag':43 'mysql':3,11,26,37,54 'node.js':14 'nodej':2 'nodejs-mysql':1 'oper':27 'packag':38 'pool':45 'promis':6,41,55 'promise-bas':5 'provid':21 'publish':18 'queri':29 'raw':36 'recent':51 'releas':52 'return':40 'simpl':23 'sporad':48 'transact':34 'unlik':35 'updat':31 'version':15 'wrapper':8","created_at":"2026-06-05T16:59:59.830615+00:00","updated_at":"2026-06-05T16:59:59.830615+00:00","problems":[{"fix":"Use `const mysql = require('nodejs-mysql').default;`","cause":"Importing the module incorrectly via require without .default.","error":"TypeError: mysql.getInstance is not a function"},{"fix":"Run `npm install mysql` to install the mysql driver.","cause":"Missing the required peer dependency 'mysql'.","error":"Error: Cannot find module 'mysql'"}],"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/alsey/nodejs-mysql#readme","github":"https://github.com/alsey/nodejs-mysql","docs":null,"changelog":null,"pypi":null,"npm":"nodejs-mysql","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}}