A lightweight Node.js library that establishes a MySQL connection through an SSH tunnel. Currently at version 1.0.6, it wraps ssh2 and mysql2 to provide a simple promise-based API for connecting to remote MySQL databases only accessible via SSH. Unlike manually managing SSH tunnels with separate libraries, mysql-ssh handles forwarding and cleanup automatically. Suitable for temporary connections, but users must call close() to avoid resource leaks. Low maintenance cadence.
npm install mysql-sshNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to a MySQL database through an SSH tunnel using private key authentication, runs a query, prints results, and closes the tunnel.
Always call mysqlssh.close() after you finish querying.
Add your own retry logic using .catch or async/await try-catch.
No direct impact on functionality; switch to Renovate for dependency management.
Ensure the SSH tunnel forwards the correct remote port to a local port, and that MySQL is reachable from the SSH server.
Check that the private key path is correct and the key has proper permissions (600). If using passphrase, add passphrase property to sshConfig.