Prompt Buddy logoPrompt Buddy

cloudflare · Cloudflare Workers Docs

Connect to a MySQL database with Cloudflare Workers

A step-by-step tutorial for building a Cloudflare Worker that connects to a MySQL database using Hyperdrive and TCP Sockets.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Connect to a MySQL database with Cloudflare Workers

A step-by-step tutorial for building a Cloudflare Worker that connects to a MySQL database using Hyperdrive and TCP Sockets.

When To Use

Use when you need to implement a connection between a Cloudflare Worker and a MySQL database using Hyperdrive for optimized performance.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/connect-to-a-mysql-database-with-cloudflare-workers-workflow-guide.mdA tutorial guide for creating a Cloudflare Workers application that connects to a MySQL database using TCP Sockets and Hyperdrive.Questions about a tutorial guide for creating a Cloudflare Workers application that connects to a MySQL database using TCP Sockets an...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m.textA step-by-step tutorial guide for connecting a Cloudflare Worker to a MySQL database using the provided npm command.Exact payloads, commands, or snippets shown in A step-by-step tutorial guide for connecting a Cloudflare Worker to a MySQL database using the provided npm command.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-2.textA text-based guide outlining the initialization steps and command requirements for setting up a MySQL connection tutorial within Cloudflare Workers.Exact payloads, commands, or snippets shown in A text-based guide outlining the initialization steps and command requirements for setting up a MySQL connection tuto...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-3.textThe shell commands required to initialize the MySQL tutorial project using the Cloudflare create command.Exact payloads, commands, or snippets shown in The shell commands required to initialize the MySQL tutorial project using the Cloudflare create command.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-4.textA sequence of shell commands to initialize the project directory and navigate to the tutorial folder.Exact payloads, commands, or snippets shown in A sequence of shell commands to initialize the project directory and navigate to the tutorial folder.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-5.textA wrangler.toml configuration file demonstrating the compatibility flags and settings required to connect a Cloudflare Worker to a MySQL database.Exact payloads, commands, or snippets shown in A wrangler.toml configuration file demonstrating the compatibility flags and settings required to connect a Cloudflar...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-6.textA wrangler.toml configuration file specifying nodejs_compat compatibility flags and a compatibility date for connecting Cloudflare Workers to a MySQL database.Exact payloads, commands, or snippets shown in A wrangler.toml configuration file specifying nodejscompat compatibility flags and a compatibility date for connectin...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-7.textA wrangler command to create a Hyperdrive configuration using a MySQL connection string.Exact payloads, commands, or snippets shown in A wrangler command to create a Hyperdrive configuration using a MySQL connection string.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-h.textA wrangler.toml configuration file demonstrating how to bind a Hyperdrive instance to a Cloudflare Worker for MySQL connectivity.Exact payloads, commands, or snippets shown in A wrangler.toml configuration file demonstrating how to bind a Hyperdrive instance to a Cloudflare Worker for MySQL c...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-h-2.textA wrangler.toml configuration file demonstrating how to bind a Hyperdrive instance to a Cloudflare Worker for MySQL connectivity.Exact payloads, commands, or snippets shown in A wrangler.toml configuration file demonstrating how to bind a Hyperdrive instance to a Cloudflare Worker for MySQL c...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-8.textA text-based guide and command sequence for installing the mysql2 package and connecting a Cloudflare Worker to a MySQL database.Exact payloads, commands, or snippets shown in A text-based guide and command sequence for installing the mysql2 package and connecting a Cloudflare Worker to a MyS...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-9.textThe shell command to install the mysql2 package required to connect a Cloudflare Worker to a MySQL database.Exact payloads, commands, or snippets shown in The shell command to install the mysql2 package required to connect a Cloudflare Worker to a MySQL database.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-10.textThe shell commands required to install the mysql2 package using pnpm for a Cloudflare Workers project.Exact payloads, commands, or snippets shown in The shell commands required to install the mysql2 package using pnpm for a Cloudflare Workers project.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-11.textThe shell commands required to install the mysql2 dependency using bun for a Cloudflare Workers project.Exact payloads, commands, or snippets shown in The shell commands required to install the mysql2 dependency using bun for a Cloudflare Workers project.
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-12.textA configuration snippet for Cloudflare Workers using compatibility flags and Hyperdrive bindings to connect to a MySQL database.Exact payloads, commands, or snippets shown in A configuration snippet for Cloudflare Workers using compatibility flags and Hyperdrive bindings to connect to a MySQ...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-13.textA configuration file containing compatibility flags, compatibility date, and Hyperdrive binding settings for connecting Cloudflare Workers to a MySQL database.Exact payloads, commands, or snippets shown in A configuration file containing compatibility flags, compatibility date, and Hyperdrive binding settings for connecti...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-14.textA JavaScript code example demonstrating how to establish a MySQL database connection within a Cloudflare Worker using Hyperdrive and the mysql2 library.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to establish a MySQL database connection within a Cloudflare Worker using...
examples/connect-to-a-mysql-database-with-cloudflare-workers-cloudflare-workers-m-15.textThe wrangler deploy command used to deploy a Cloudflare Worker that connects to a MySQL database.Exact payloads, commands, or snippets shown in The wrangler deploy command used to deploy a Cloudflare Worker that connects to a MySQL database.

What This Skill Covers

  • In this tutorial, you will learn how to create a Cloudflare Workers application and connect it to a MySQL database using TCP Sockets and Hyperdrive. The Work...
  • Main sections: Tags, Prerequisites, 1\. Create a Worker application, 2\. Enable Node.js compatibility, 3\. Create a Hyperdrive configuration.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://developers.cloudflare.com/workers/tutorials/mysql