Registry / database / extract-mysql-schema

extract-mysql-schema

JSON →
library1.0.2jsnpmunverified

A CLI tool to extract MySQL database schemas into JSON or SQL files, supporting tables, stored procedures, seed data, and patches. Current version 1.0.2, with moderate release cadence (no recent updates). Key differentiators: generates dependency-ordered SQL files, supports external connection files, and offers options for debug mode and procedure ISV inclusion. Alternatives like mysqldump are more comprehensive but this tool provides lighter, scriptable schema extraction.

npm install extract-mysql-schema
INSTALL
IMPORT
SIG · EXTRACT-MYSQL-SCHE
E
extract-mysql-schema
databasejavascriptv1.0.2
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.

CLI tool
npx extract-mysql-schema --configFile <path>
Running without --configFile or using require() directly
This is a CLI tool, not a library. Use npx or global install. No programmatic API is exported.

Creates a config file and runs the CLI to extract schema as JSON or SQL files.

// First, create a config file config.js: module.exports = { connection: { host: 'localhost', user: 'root', password: 'password', database: 'mydb', port: 3306 } }; // Then run: npx extract-mysql-schema --configFile config.js --outputFile schema.json // For SQL files: npx extract-mysql-schema --configFile config.js --writeSql
Debug
Known issues
gotchaRequires a configuration file with a 'connection' object; plain command-line flags for connection details are not supported.
fix
Create a .js or .json config file with { connection: { host, user, password, database } }.
affects: >=0.0.0
gotchaThe --configFile flag is required; no other connection method exists.
fix
Always specify --configFile <path>.
affects: >=0.0.0
deprecatedThe tool may be unmaintained; last release 1.0.2, no updates in years.
fix
Consider alternatives like mysqldump or mysql-export for ongoing support.
affects: >=0.0.0
gotchaPassword is passed in plaintext in config file; no encryption or .env support.
fix
Use environment variables or a secure secret manager, and avoid committing config files.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
Missing mysql driver dependency.
fix
Run 'npm install mysql' in the project or install globally with 'npm install -g extract-mysql-schema'.
Error: Config file not found: <path>
The --configFile path is incorrect or file doesn't exist.
fix
Ensure the path is correct and the file exists; use an absolute path or './relative'.
TypeError: Cannot read property 'host' of undefined
Config file does not have a 'connection' property.
fix
Ensure config exports an object with { connection: { host, user, password, database } }.
Error: getaddrinfo ENOTFOUND <host>
MySQL host unreachable or misconfigured.
fix
Check hostname and network connectivity; ensure MySQL server is running and accessible.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
mysqlrequiredMySQL database driver for Node.js used to connect and query the database
yargsrequiredCommand-line argument parsing for CLI usage
Agent activity
9 hits · last 30 days
node
6
Resources
extract-mysql-schema — npm install extract-mysql-schema · libregistry