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.
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
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/connect-to-a-mysql-database-with-cloudflare-workers-workflow-guide.md | A 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.text | A 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.text | A 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.text | The 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | The 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.text | The 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.text | The 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.text | A 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.text | A 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.text | A 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.text | The 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
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.cloudflare.com/workers/tutorials/mysql
