The Cloudflare team has announced support for MySQL in Cloudflare Workers and Hyperdrive, enabling developers to connect to their existing MySQL databases directly from Workers, without region restrictions. This is made possible by the Hyperdrive solution, which pools connections to databases globally, eliminates unnecessary roundtrips, and provides integrated caching to offload popular queries from databases. The team has also improved Node.js compatibility for the mysql package, allowing it to work on the Workers runtime, and has released a new version of the mysql2 package that supports static parsing without using eval(), making it compatible with Cloudflare Workers.
To get started, developers can create new Hyperdrive configurations for MySQL databases hosted anywhere, using the Wrangler CLI or the dashboard, and configure their Wrangler configuration file to set up Node.js compatibility flags and specify the Hyperdrive binding. From there, they can use existing MySQL drivers with custom connection credentials provided by Hyperdrive, leveraging Cloudflare's network to speed up routing. The team is committed to iterating on support for MySQL during the beta phase and expanding the feature set of Hyperdrive to make it more flexible for full-stack workloads and performant for building global apps on Workers.