{"id":42404,"library":"anysql-mysql","title":"anysql-mysql","description":"MySQL implementation of the AnySQL API (v0.2.1). Provides a unified interface for MySQL database operations, abstracting over the mysql driver. This package is part of the AnySQL ecosystem aimed at database-agnostic querying. It is stable but minimally maintained, with no recent updates since 2017. Differentiator: it offers a consistent API if you already use AnySQL for other databases, but standalone use is limited. Release cadence: sporadic.","status":"maintenance","version":"0.2.1","language":"javascript","source_language":"en","source_url":"git://github.com/object-layer/anysql-mysql","tags":["javascript"],"install":[{"cmd":"npm install anysql-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add anysql-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add anysql-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver for Node.js","package":"mysql","optional":false},{"reason":"Core AnySQL API, defines the interface this package implements","package":"anysql","optional":false}],"imports":[{"note":"Default import is the main entry point; named imports not provided.","wrong":"import {anySQL} from 'anysql-mysql';","symbol":"default","correct":"import anySQL from 'anysql-mysql';"},{"note":"CommonJS require returns the default export as an object.","wrong":"const {anySQL} = require('anysql-mysql');","symbol":"default (require)","correct":"const anySQL = require('anysql-mysql');"},{"note":"Configuration must be an object, not a connection string.","wrong":"const db = anySQL('host=localhost user=root');","symbol":"config object","correct":"const db = anySQL({ host: 'localhost', user: 'root', password: 'pass', database: 'test' });"}],"quickstart":{"code":"import anySQL from 'anysql-mysql';\n\nconst db = anySQL({\n  host: process.env.DB_HOST ?? 'localhost',\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASS ?? 'password',\n  database: process.env.DB_NAME ?? 'test'\n});\n\nasync function init() {\n  await db.query('CREATE TABLE IF NOT EXISTS users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))');\n  await db.query('INSERT INTO users (name) VALUES (?)', ['Alice']);\n  const results = await db.query('SELECT * FROM users');\n  console.log(results);\n}\n\ninit().catch(console.error);","lang":"typescript","description":"Shows creating a connection and running queries with parameterized inputs."},"warnings":[{"fix":"Use a separate connection pool or handle connections manually.","message":"anysql-mysql does not support connection pooling. Each call creates a new connection.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use async/await or .then().","message":"The API is synchronous-style but uses Promises under the hood. Callbacks not supported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'mysql2' driver or switch to a more modern library like 'mysql2/promise'.","message":"The package uses the deprecated 'mysql' driver which has known authentication issues with MySQL 8.0+.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Install @types/anysql-mysql if available, or create a declaration file.","message":"No TypeScript type definitions are included; using with TypeScript requires custom types.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2017':49 'abstract':19 'agnost':36 'aim':32 'alreadi':58 'anysql':2,8,30,60 'anysql-mysql':1 'api':9,55 'cadenc':70 'consist':54 'databas':17,35,63 'database-agnost':34 'differenti':50 'driver':23 'ecosystem':31 'implement':5 'interfac':14 'javascript':72 'limit':68 'maintain':43 'minim':42 'mysql':3,4,16,22 'offer':52 'oper':18 'packag':25 'part':27 'provid':11 'queri':37 'recent':46 'releas':69 'sinc':48 'sporad':71 'stabl':40 'standalon':65 'unifi':13 'updat':47 'use':59,66 'v0.2.1':10","created_at":"2026-06-05T16:54:49.213527+00:00","updated_at":"2026-06-05T16:54:49.213527+00:00","problems":[{"fix":"Alter MySQL user to use mysql_native_password: ALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password';","cause":"MySQL 8.0 uses caching_sha2_password by default; the 'mysql' driver used by anysql-mysql does not support it.","error":"Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client"},{"fix":"Install both packages: npm install anysql anysql-mysql","cause":"Missing peer dependency 'anysql' which is required at runtime.","error":"Error: Cannot find module 'anysql'"},{"fix":"Use default import: import anySQL from 'anysql-mysql'; const db = anySQL({...});","cause":"The import was not correctly obtained; likely used a named import or misconfigured the connection object.","error":"TypeError: db.query 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/object-layer/anysql-mysql#readme","github":"git://github.com/object-layer/anysql-mysql","docs":null,"changelog":null,"pypi":null,"npm":"anysql-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}}