database-js-mysql is a wrapper for the `mysql` package, primarily designed to integrate MySQL functionality into applications using the `database-js` abstraction layer. It provides a promise-based API for handling MySQL connections and executing queries, offering both standalone usage and integration with the `database-js` Connection class. As of its latest stable version, 1.1.3, released over seven years ago, the package relies on CommonJS modules and older JavaScript syntax. Its key differentiator was providing a consistent `database-js` interface for MySQL, including support for parameterized queries and streamlined connection management, which was useful for abstracting database interactions in its ecosystem.
npm install database-js-mysqlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to establish a standalone MySQL connection using `database-js-mysql` and execute a simple query. It uses environment variables for sensitive credentials and handles connection opening, querying, and closing with async/await.
Consider migrating to actively maintained database drivers like `mysql2` or newer ORMs/query builders.
Use `require()` syntax for all imports from this package and ensure your project configuration is set up for CommonJS.
Audit the `mysql` dependency for known CVEs. For new projects, prefer `mysql2` which is actively maintained and supports promises and modern features.
Ensure that the paths provided for `ssl[ca]`, `ssl[key]`, and `ssl[cert]` are absolute, correct, and that the Node.js process has read permissions for these files. Test SSL connectivity thoroughly.
Change your import statement to `const mysql = require('database-js-mysql');` and ensure your project is configured for CommonJS, or use a tool like Webpack/Rollup to transpile.Verify that the MySQL server is running, check the `Hostname`, `Port`, `Username`, and `Password` in your connection options, and ensure no firewalls are preventing access.
Double-check your `Username` and `Password` in the connection object. Ensure the MySQL user has privileges to connect from the specified host and access the target database.
Ensure `let connection = await mysql.open({...});` is used to properly resolve the promise and get the connection object before calling methods on it.