shiichan

Cloudflare Hyperdrive Now Supports MySQL — Zero Code Changes for Blazing-Fast Connections!

Hey everyone, it's me, Shiichan! Today I've got news for anyone building on Cloudflare Workers — connecting to your database just got easier.

Cloudflare Changelog developers.cloudflare.com

What was announced?

According to the Cloudflare Changelog, MySQL support in Hyperdrive is now generally available. You can now connect to any MySQL database from your Workers using Hyperdrive.

Hyperdrive is the tool that makes regional databases fast when you connect from Cloudflare Workers. It cuts out unnecessary network round trips during connection setup, pools database connections globally, and can even cache query results.

The story so far

Until now, Hyperdrive only supported PostgreSQL. Projects running on MySQL couldn't tap into any of Hyperdrive's speed benefits.

What changes

If you're on MySQL, you can now connect through Hyperdrive using your existing drivers, ORMs, and query builders — no code changes required. You just use Hyperdrive's secure credentials. MySQL is priced the same as Postgres, too, so there's no extra cost to worry about when you try it out.

In short, if you run a regional MySQL database, you can now get the same Hyperdrive benefits — faster connections, global pooling, and caching — when you build Workers apps against it.

Dive Deep

The original post includes a sample using the mysql2/promise driver. Here's the gist:

import { createConnection } from "mysql2/promise";

export default {
  async fetch(request, env, ctx) {
    const connection = await createConnection({
      host: env.HYPERDRIVE.host,
      user: env.HYPERDRIVE.user,
      password: env.HYPERDRIVE.password,
      database: env.HYPERDRIVE.database,
      port: env.HYPERDRIVE.port,
      disableEval: true, // Required for Workers compatibility
    });

    const [results, fields] = await connection.query("SHOW tables;");
    ctx.waitUntil(connection.end());

    return new Response(JSON.stringify({ results, fields }), {
      headers: {
        "Content-Type": "application/json",
        "Access-Control-Allow-Origin": "*",
      },
    });
  },
};

The connection pulls host, user, password, database, and port from env.HYPERDRIVE. The key detail is disableEval: true — it's required for the driver to work inside Workers. If you're using TypeScript, the post also shows declaring HYPERDRIVE: Hyperdrive on your Env interface.

Wrap-up

  • MySQL support in Hyperdrive is now generally available
  • Previously Postgres-only, Hyperdrive now speeds up MySQL connections from Workers too
  • Works with your existing drivers, ORMs, and query builders — no code changes needed
  • Pricing matches Postgres

If you run a regional MySQL database and want to use it from Cloudflare Workers, or you've been waiting for Hyperdrive to support something other than Postgres, this update is for you.