{"id":43310,"library":"mysql-native","title":"mysql-native","description":"A pure-JavaScript MySQL client for Node.js (v0.4.7) that implements the MySQL wire protocol directly, requiring no native C++ addons or external MySQL runtime. It supports TCP and UNIX socket connections, automatic prepared statement caching, pipelined queries, and transparent handling of row and binary row packets. Released under a rolling cadence, this package is a legacy choice superseded by more modern MySQL drivers like mysql2 or mysql (felixge). It is best suited for older Node.js environments (>=0.6.0) or educational exploration of protocol internals.","status":"maintenance","version":"0.4.7","language":"javascript","source_language":"en","source_url":"[{'type': 'git', 'url': 'http://github.com/sidorares/nodejs-mysql-native'}]","tags":["javascript","mysql","native","sql","database","client","pool"],"install":[{"cmd":"npm install mysql-native","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-native","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-native","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is an object with named functions; there is no default import.","wrong":"const mysql = require('mysql-native'); const client = mysql.createClient();","symbol":"createClient","correct":"import { createClient } from 'mysql-native'"},{"note":"Both named import and property access work; no ESM/CJS differences pre-date ESM.","wrong":"const client = require('mysql-native').createTCPClient();","symbol":"createTCPClient","correct":"import { createTCPClient } from 'mysql-native'"}],"quickstart":{"code":"import { createTCPClient } from 'mysql-native';\n\nconst client = createTCPClient('localhost', 3306);\nclient.auto_prepare = true;\n\nclient.on('error', (err) => console.error(err));\n\nclient.auth('testdb', 'testuser', 'testpass');\n\nclient.query('SELECT 1+1 AS result')\n  .on('field', (field) => console.log('Field:', field))\n  .on('row', (row) => console.log('Row:', row))\n  .on('end', () => client.close());","lang":"typescript","description":"Connects to MySQL, authenticates, runs a simple query with event listeners, and closes the connection."},"warnings":[{"fix":"Migrate to a maintained driver like mysql2.","message":"Package has not been updated since 2012; consider using mysql2 or mysql.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Set client.auto_prepare = true before calling execute().","message":"auto_prepare must be set to true for execute() to work without manual prepare.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'row' for rows, 'field' for field metadata, 'end' for result completion.","message":"Event names on query/execute commands are lowercase (e.g., 'row', 'field', 'end') but Node.js style would expect 'row' etc. Already lowercase, but no 'data' event.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.6.0':81 'addon':24 'automat':36 'best':75 'binari':48 'c':23 'cach':39 'cadenc':55 'choic':61 'client':9,93 'connect':35 'databas':92 'direct':19 'driver':67 'educ':83 'environ':80 'explor':84 'extern':26 'felixg':72 'handl':44 'implement':14 'intern':87 'javascript':7,88 'legaci':60 'like':68 'modern':65 'mysql':2,8,16,27,66,71,89 'mysql-nat':1 'mysql2':69 'nativ':3,22,90 'node.js':11,79 'older':78 'packag':57 'packet':50 'pipelin':40 'pool':94 'prepar':37 'protocol':18,86 'pure':6 'pure-javascript':5 'queri':41 'releas':51 'requir':20 'roll':54 'row':46,49 'runtim':28 'socket':34 'sql':91 'statement':38 'suit':76 'supersed':62 'support':30 'tcp':31 'transpar':43 'unix':33 'v0.4.7':12 'wire':17","created_at":"2026-06-05T16:59:11.250142+00:00","updated_at":"2026-06-05T16:59:11.250142+00:00","problems":[{"fix":"Explicitly pass '127.0.0.1' instead of 'localhost' when calling createTCPClient.","cause":"Default host is IPv6 localhost; older Node versions or configurations may not resolve.","error":"Error: connect ECONNREFUSED ::1:3306"},{"fix":"Ensure you create a client first: const client = createTCPClient(); then client.auth(...).","cause":"Incorrect import — auth is a method on the client instance, not a standalone function.","error":"TypeError: client.auth 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":"http://github.com/sidorares/nodejs-mysql-native","github":"[{'type': 'git', 'url': 'http://github.com/sidorares/nodejs-mysql-native'}]","docs":null,"changelog":null,"pypi":null,"npm":"mysql-native","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}}