원클릭으로
prisma-database-setup-mysql
MySQL Setup. Reference when using this Prisma feature.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
MySQL Setup. Reference when using this Prisma feature.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
prisma db execute. Reference when using this Prisma feature.
prisma db pull. Reference when using this Prisma feature.
prisma db push. Reference when using this Prisma feature.
prisma db seed. Reference when using this Prisma feature.
prisma debug. Reference when using this Prisma feature.
prisma dev. Reference when using this Prisma feature.
| name | prisma-database-setup-mysql |
| description | MySQL Setup. Reference when using this Prisma feature. |
| license | MIT |
| metadata | {"author":"prisma","version":"7.0.0"} |
Configure Prisma with MySQL (or MariaDB).
In prisma/schema.prisma:
datasource db {
provider = "mysql"
}
generator client {
provider = "prisma-client"
output = "../generated"
}
In prisma.config.ts:
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
datasource: {
url: env('DATABASE_URL'),
},
})
In .env:
DATABASE_URL="mysql://user:password@localhost:3306/mydb"
mysql://USER:PASSWORD@HOST:PORT/DATABASE
Prisma ORM 7 uses the query compiler by default, so you must use a driver adapter.
Install adapter and driver:
npm install @prisma/adapter-mariadb mariadb
Instantiate Prisma Client with the adapter:
import 'dotenv/config'
import { PrismaClient } from '../generated/client'
import { PrismaMariaDb } from '@prisma/adapter-mariadb'
const adapter = new PrismaMariaDb({
host: 'localhost',
port: 3306,
connectionLimit: 5,
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DATABASE,
})
const prisma = new PrismaClient({ adapter })
PlanetScale uses MySQL but requires specific settings because it doesn't support foreign key constraints.
In prisma/schema.prisma:
datasource db {
provider = "mysql"
relationMode = "prisma" // Emulate foreign keys in Prisma
}
MySQL has a connection limit. Adjust connection pool size in URL:
DATABASE_URL="mysql://...?connection_limit=5"
MySQL 5.7+ supports JSON. MariaDB 10.2+ supports JSON (as an alias for LONGTEXT with check constraints). Prisma handles this, but verify your version.