Registry / devops / mysql-parse

mysql-parse

JSON →
library3.0.2jsnpmunverified

Parse MySQL connection strings to extract user, password, host, port, and database parameters, producing output compatible with mysql or mysqldump command-line clients. Version 3.0.2 supports Node >=20 and ESM-only. Unlike generic URI parsers, it specifically handles MySQL URIs and outputs formatted CLI flags. The package is small, focused, and provides both a CLI tool and a module API. Release cadence is low; no recent major changes.

npm install mysql-parse
INSTALL
IMPORT
SIG · MYSQL-PARSE
M
mysql-parse
devopsjavascriptv3.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.

parseUri
import { parseUri } from 'mysql-parse'
const { parseUri } = require('mysql-parse')
ESM-only since v3; CommonJS require() will throw.
buildMysqlParams
import { buildMysqlParams } from 'mysql-parse'
import mysqlParse from 'mysql-parse'
No default export; must use named import.
mysql-parse (CLI)
npx mysql-parse <uri>
mysql-parse (<uri>)
CLI usage is via command line; no parentheses around URI.

Shows how to parse a MySQL URI and build CLI parameters for mysqldump, with named imports and execSync integration.

import { parseUri, buildMysqlParams } from 'mysql-parse' const uri = 'mysql://user:pass@localhost:3306/mydb' // Parse URI into components const params = parseUri(uri) console.log(params.user) // 'user' // Build CLI arguments string const args = buildMysqlParams(uri) console.log(args) // '-u user -ppass -h localhost -P 3306 mydb' // Use with exec import { execSync } from 'child_process' const dump = execSync(`mysqldump ${buildMysqlParams('mysql://user:pass@localhost:3306/mydb')} > dump.sql`)
Debug
Known issues
breakingPackage is ESM-only since version 3. CommonJS require() will fail.
fix
Use import syntax or enable ESM in your project.
affects: >=3.0.0
gotchaThe password in the CLI output is prefixed with -p without a space, which is standard for mysql client but may be unexpected.
fix
Do not manually add a space after -p; the output is intentionally -ppassword.
affects: *
gotchaIf the database name is omitted in the URI, buildMysqlParams will not include it, potentially causing commands to fail.
fix
Ensure URI includes a database path segment if needed.
affects: *
gotchaThe package uses the last argument as the database name; passing additional options after mysql-parse will be misinterpreted.
fix
Place extra options before $(mysql-parse ...) as shown in README.
affects: *
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Package is ESM-only; project not configured for ESM.
fix
Add "type": "module" to package.json or use .mjs extension.
TypeError: mysql_parse_1.default is not a function
Using default import instead of named import.
fix
Use import { parseUri, buildMysqlParams } from 'mysql-parse'.
Error: Cannot find module 'mysql-parse'
Package not installed or incorrect import path.
fix
Install package: npm install mysql-parse
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
mysql-parse — npm install mysql-parse · libregistry