Registry / database / wait-for-mysql

wait-for-mysql

JSON →
library1.0.0jsnpmunverified

A Node.js utility that polls a MySQL server until a connection is available, with optional custom query validation. Version 1.0.0 is the current stable release; no further updates have been published since its initial release. It supports both programmatic use and CLI invocation, but has no active maintenance or release cadence. Unlike more modern tools (e.g., wait-on, docker-compose healthchecks), this package is minimal, single-purpose, and does not support ESM or TypeScript natively.

npm install wait-for-mysql
INSTALL
IMPORT
SIG · WAIT-FOR-MYSQL
W
wait-for-mysql
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import waitForMy from 'wait-for-mysql'
✗ const waitForMy = require('wait-for-mysql')
ESM syntax works if you use a module bundler or Node.js with ESM, but the package itself is CJS only. In CommonJS, use require().
wait
✓ import { wait } from 'wait-for-mysql'
✗ import wait from 'wait-for-mysql'
The named export 'wait' is the main function. Default import gives the same object, but this is explicit.
WaitConfig
✓ import type { WaitConfig } from 'wait-for-mysql'
✗ import { WaitConfig } from 'wait-for-mysql'
No TypeScript types are shipped; this is a conceptual type only if you define it yourself.

Waits for MySQL to accept connections, then runs a validation query.

import { wait } from 'wait-for-mysql'; const config = { host: process.env.MYSQL_HOST ?? 'localhost', port: parseInt(process.env.MYSQL_PORT ?? '3306'), username: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test', query: 'SELECT 1', quiet: false }; wait(config).then(() => { console.log('MySQL is ready'); }).catch(err => { console.error('MySQL never became available:', err); });
Debug
Known issues
gotchaThe package is not updated for newer Node.js versions; may fail silently with Node >= 14.
fix
Consider using a more maintained alternative like wait-on or a simple loop with mysql2.
affects: >=1.0.0
deprecatedUses mysql (MySQL2) under the hood, which is deprecated in favor of mysql2.
fix
Switch to mysql2 directly and implement your own polling.
affects: >=1.0.0
gotchaThe CLI binary 'wait-for-mysql' may conflict with other packages on PATH.
fix
Use npx or run via node_modules/.bin/wait-for-mysql.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
The package depends on 'mysql' which may not be installed.
fix
Run 'npm install mysql' alongside wait-for-mysql.
TypeError: waitForMy.wait is not a function
Using default import instead of named import in ESM.
fix
Use 'import { wait } from 'wait-for-mysql'' or use CommonJS require().
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL is not running or host/port is wrong.
fix
Ensure MySQL is started and config host/port match your server.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
wait-for-mysql — npm install wait-for-mysql · libregistry