Community journal

The latest from the MySQL community

Ideas, releases, practical guides, and perspectives from the people building with MySQL.

Follow the feed
Showing entries 1 to 10 of 10 « Previous | Next »
Displaying posts with tag: Node Tutorials (reset)
NodeJS MySQL Create Database

Create a MySQL database from Node.js with one query. The trick is connecting without naming a database first, running CREATE DATABASE IF NOT EXISTS, then verifying the schema exists. Here is how to do it with mysql2 and handle the failures you will hit in production. The SQL you need IF NOT EXISTS is the […]

NodeJS MySQL Select Unique

I ran SELECT UNIQUE age FROM users on a table with a duplicated age. It returned 22, 17 and 15, the same rows SELECT DISTINCT returns. On MySQL 8 that statement stops before the table is read, because UNIQUE never entered the server’s select grammar, and DISTINCT is the modifier both servers accept. Which unique […]

Node.js MySQL Insert Record

I pointed a Node script at a MySQL table and the connection succeeded. The INSERT failed on a name containing an apostrophe. Pasting values into the SQL string holds until real data arrives, then a name like O’Brien ends the run with a syntax error. Placeholders are the fix, and the driver escapes every value […]

NodeJS MySQL Select Record

RowDataPacket is the name MySQL hands back to Node.js, and it is the line most readers get stuck on. This is the select step end to end, from a running MySQL server to a callback whose rows you can read. What you need to run MySQL SELECT queries in NodeJS Three things, in dependency order. […]

NodeJS MySQL Drop Table

DROP TABLE crashed my Node process when I re-ran it without a guard, and the fix turns that crash into a warning. I built every code path below on Node 26.7.0 with mysql 2.18.1 and mysql2 3.24.4 against MariaDB 10.11.14. I captured the terminal output as images so what you run matches what I saw. […]

NodeJS MySQL Create Table

I ran node app.js once and the users table appeared, then I ran it again and MySQL returned Table users already exists. If you copy the Node.js MySQL create table snippet from an older tutorial you expect it to be safe to rerun because the code looks like any other setup script, so the duplicate […]

NodeJS MySQL Create Connection

I rebuilt this MySQL connection from scratch on Node 26 with mysql2 3.24.4 because the old page still taught the unmaintained mysql package. It left every error to a throw that crashes your process. I ran each snippet below against a local MariaDB 10.11 on 3306, so every ER_ACCESS_DENIED_ERROR you see came from a run […]

Node.js and MySQL Connection Pool Example

I threw a per-request MySQL connection into a small Node API and watched it limp under concurrent load, so I rebuilt it with a mysql2 pool and kept the receipts. I created the pool with createPool on Node v26.7.0 and mysql2 3.24.4, ran pool.query and pool.getConnection against a local host, and got ER_ACCESS_DENIED_NO_PASSWORD_ERROR back because […]

Synchronize MySQL and IndexedDB in an Offline-First App

When you build an offline-first app, the question is what happens to a change while there is no network. The answer is a queue that writes to IndexedDB first, pushes to MySQL, and clears the local copy only after the server confirms. The library versions behind that run are Express 5.2.1 and mysql2 3.24.4, both […]

Twitter Login Using Node and MySQL

Twitter login with Node breaks every few years because the pieces move under it. I rebuilt this app on the current releases and fixed each place where the old code stops working, so you can follow it step by step and finish with a working sign-in. Live Demo Download Code Pick the right X auth […]