Skip to content

mysqljs

A pure JavaScript MySQL client for Node.js that talks directly to MySQL servers.mysqljs/mysql

Stars
18.6k
Forks
2.5k
Licence
MIT
Language
JavaScript
Last update
2.4 years ago
Type
Library

No commits in over a year — check for forks or alternatives before adopting.

What it is

This is a Node.js library that lets JavaScript code connect to a MySQL database and run queries. It is written entirely in JavaScript and implements the MySQL wire protocol itself, so it does not depend on a separate native MySQL driver. Developers use it to read and write data from Node.js server applications.

  • Connect a Node.js web server to a MySQL database and run SELECT, INSERT, UPDATE and DELETE queries
  • Build a REST API backed by MySQL data
  • Run a script that imports or exports rows from a MySQL table

Great for

  • Node.js backend developers who need to query a MySQL database
  • Teams that want a pure JavaScript driver with no native compilation step
  • Projects that already run MySQL and want a widely used Node.js client

Not ideal for

  • People who are not writing Node.js code, since it is a JavaScript library
  • Projects that need a newer, actively promoted driver, because the README was not sufficient to confirm current maintenance status beyond the last push date
  • Users of other databases such as PostgreSQL, which need a different client
Step-by-step guide: how to use mysqljsInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js · A running MySQL server

    Install the package from npm

    npm install mysql
  2. 2

    Run it

    • Install the package with npm in your Node.js project
    • Create a connection object with your host, user, password and database name
    • Call connect on the connection and run a query
    • Close the connection with end when finished
  3. 3

    Get the most out of it

    • Use connection pooling if your application runs many queries concurrently
    • Use parameterized queries or escaping to avoid SQL injection
    • Check the README for SSL and timeout options when connecting to remote servers

Downloads

Strengths

  • Pure JavaScript implementation with no native build dependency
  • Widely used, with about 18,600 GitHub stars at the time of metadata capture
  • Open source under the MIT license

Trade-offs

  • The README provided was truncated, so detailed feature and API coverage could not be fully verified here
  • No formal release is listed, so users must rely on the repository's current code or package registry versions
  • Being a low-level driver, it leaves query building and schema design to the developer

How it compares

ProjectStarsTypeLevelUpdatedBest for
mysql (this)18.6kLibraryintermediate2.4 years agoNode.js backend developers who need to query a MySQL database
sequelize30.3kLibraryintermediate5 days agoNode.js backend developers who use a relational SQL database
typeorm36.7kLibraryintermediate8 days agoNode.js or TypeScript developers building apps backed by a relational database
knex20.3kLibraryintermediate4 months agoNode.js developers who need to talk to a SQL database from application code
kysely14.3kLibraryintermediate4 days agoTypeScript developers who want SQL control without losing compile-time type checks
ruoyi-vue-pro40.2kFrameworkadvanced5 days agoJava developers building an internal admin or back-office system

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.