Learn how to integrate Bolt.new AI with MySQL in 2025 using simple steps to boost workflows and build smarter, faster applications.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
To integrate Bolt.new with MySQL, you simply build a normal backend inside Bolt.new (usually Node.js) and connect to MySQL using a standard MySQL driver with environment variables for credentials. Bolt.new doesn’t have a special or proprietary database connector — you use the same SDKs and patterns you would use in any local project. The integration works because Bolt.new runs your backend code in a sandboxed container, and that container can open outbound connections to your remote MySQL server. You store your DB credentials in Bolt.new environment variables, import a MySQL client, create a connection pool, and use it in your API routes.
You’re not integrating “Bolt AI” with MySQL. You’re integrating the backend you build inside the Bolt.new workspace with MySQL, the same way you would in any full-stack project: using a MySQL client library and environment variables.
Bolt.new provides:
You provide:
In Bolt.new, open the “Environment Variables” panel and set:
These values come from your actual MySQL provider.
npm install mysql2
mysql2 is the most commonly used modern driver. It works in Bolt.new’s Node runtime without issues.
Inside Bolt.new, create something like /lib/db.js:
// lib/db.js
import mysql from "mysql2/promise";
// Create a connection pool (recommended)
export const pool = mysql.createPool({
host: process.env.MYSQL_HOST, // your environment variables
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DATABASE,
waitForConnections: true,
connectionLimit: 10, // safe default for small dev setups
queueLimit: 0
});
Example: /api/users.js
// api/users.js
import { pool } from "../lib/db.js";
export default async function handler(req, res) {
try {
const [rows] = await pool.query("SELECT id, name FROM users"); // simple query
res.json({ success: true, data: rows });
} catch (err) {
res.status(500).json({ success: false, error: err.message });
}
}
This route runs in Bolt.new’s backend runtime and communicates with your external MySQL instance over the network.
But inside Bolt.new, during development, the workflow is exactly the same — you code normally, provide env vars, and connect through mysql2.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.