Database
MySQL
Set up a MySQL database with Drizzle or Prisma — self-hosted or via PlanetScale's serverless branching platform.
New — Available as of the latest
create-fusion-stackrelease.
Overview
Selecting MySQL scaffolds a Drizzle or Prisma client configured for the MySQL dialect. For managed hosting, PlanetScale provides a serverless MySQL platform with a Git-like branching workflow.
Scaffolded Files
src/
└── db/
├── index.ts ← database client
└── schema.ts ← table definitions
drizzle.config.ts ← Drizzle dialect config (Drizzle only)
prisma/
└── schema.prisma ← data model (Prisma only)With Drizzle
// src/db/index.ts
import { drizzle } from 'drizzle-orm/mysql2'
import mysql from 'mysql2/promise'
import * as schema from './schema'
const pool = mysql.createPool({ uri: process.env.DATABASE_URL! })
export const db = drizzle(pool, { schema, mode: 'default' })// src/db/schema.ts
import { mysqlTable, serial, text, timestamp } from 'drizzle-orm/mysql-core'
export const users = mysqlTable('users', {
id: serial('id').primaryKey(),
email: text('email').notNull().unique(),
createdAt: timestamp('created_at').defaultNow().notNull(),
})With Prisma
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}Environment Variables
# .env.local
DATABASE_URL=mysql://user:password@localhost:3306/mydbPlanetScale
PlanetScale replaces the standard MySQL connection with the @planetscale/database serverless driver — no persistent connections needed, works on edge runtimes.
DATABASE_URL=mysql://<user>:<password>@<host>.connect.psdb.cloud/<db>?ssl={"rejectUnauthorized":true}See DB Providers for the full PlanetScale setup.