Registry / database / mysqldump

mysqldump

JSON →
library3.2.0jsnpmunverified

Create MySQL database dumps programmatically from Node.js. Version 3.2.0 (stable) provides both file-based and in-memory dump outputs, with built-in TypeScript declarations. Supports dumping schema, data, and triggers separately. Notable differentiators: returns structured dump objects, supports compressed output (.gz), and offers SSL options including Amazon RDS. Typically receives minor updates; active maintenance.

npm install mysqldump
INSTALL
IMPORT
SIG · MYSQLDUMP
M
mysqldump
databasejavascriptv3.2.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.

mysqldump (default)
import mysqldump from 'mysqldump';
const mysqldump = require('mysqldump');
Default export is a function. ESM import is recommended; CommonJS require also works.
DumpReturn
import type { DumpReturn } from 'mysqldump';
const { DumpReturn } = require('mysqldump');
DumpReturn is a TypeScript interface, not a runtime value. Use type import with ESM.
ConnectionOptions
import type { ConnectionOptions } from 'mysqldump';
import { ConnectionOptions } from 'mysqldump';
ConnectionOptions is a TypeScript interface, use type import for correct transpilation.

Creates a MySQL dump in memory, logging the schema and data separately.

import mysqldump from 'mysqldump'; const dump = await mysqldump({ connection: { host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'my_database', }, }); console.log('Schema:', dump.dump.schema); console.log('Data:', dump.dump.data);
Debug
Known issues
gotchaThe dump function is asynchronous and returns a Promise. Must be awaited or handled with .then()
fix
Use await mysqldump() or mysqldump().then(result => ...)
affects: >=3.0.0
gotchaWhen dumping to file, the function does not return the dump object unless you omit dumpToFile. To get both file and data, call twice or use in-memory then write manually.
fix
Use in-memory dump and write to file separately with fs.writeFileSync
affects: >=3.0.0
breakingVersion 3.0.0 changed from callback-based to Promise-based API. Callbacks no longer supported.
fix
Convert callback(err, result) to await mysqldump()
affects: >=3.0.0
gotchaTypeScript interface DumpReturn is not exported as a value; importing it without 'type' in ESM may cause runtime errors with some transpilers.
fix
Use import type { DumpReturn } from 'mysqldump';
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module 'mysqldump'
Package not installed or import path wrong.
fix
Run: npm install mysqldump
Property 'dump' does not exist on type 'Promise<DumpReturn>'
Missing await before mysqldump() call.
fix
Change to: const result = await mysqldump(options);
TypeError: mysqldump is not a function
Importing module incorrectly, e.g., using named import for default export.
fix
Use: import mysqldump from 'mysqldump';
Upgrade
Version history
3.2.0latest on npm
Audit
Dependencies
@types/nodeoptionalRequired for TypeScript usage to provide Node.js type definitions (e.g., Buffer, stream)
Agent activity
4 hits · last 30 days
node
4
Resources
mysqldump — npm install mysqldump · libregistry