MySQL
Managed MySQL with automated backups and private internal networking.
Supported versions
Section titled “Supported versions”StackBlaze supports MySQL 8.0 and MySQL 8.4. MySQL 8.4 is the current LTS release and is recommended for new projects. Both versions include full InnoDB support, JSON functions, window functions, and CTEs.
| Version | Status | Notes |
|---|---|---|
| MySQL 8.4 | Recommended | LTS release, default for new instances |
| MySQL 8.0 | Supported | EOL January 2026, consider migrating |
Creating a MySQL instance
Section titled “Creating a MySQL instance”From + Service → Databases, add MySQL. Pick version, disk size, and plan.
Attach it from another service’s Variables. DATABASE_URL is injected.
Connection strings
Section titled “Connection strings”Internal (recommended for production)
Section titled “Internal (recommended for production)”Services in the same environment reach MySQL by service name on the private network. No public exposure.
mysql://user:password@[service-name]:3306/dbnameExternal (for local development tools)
Section titled “External (for local development tools)”Use the external connection string for GUI clients like TablePlus, MySQL Workbench, or DBeaver. Connections are secured via SSL. Find the external URL in Settings → Connection.
mysql://user:password@db.stackblaze.cloud:3306/dbname?ssl=trueRunning migrations
Section titled “Running migrations”Configure a pre-deploy command under Settings → Deploy → Pre-deploy command to ensure migrations run before new traffic is routed to your service.
Prisma
Section titled “Prisma”npx prisma migrate deployFlyway
Section titled “Flyway”flyway -url=jdbc:mysql://[service-name]:3306/dbname \ -user=$DB_USER \ -password=$DB_PASSWORD \ migrateLiquibase
Section titled “Liquibase”liquibase \ --url=jdbc:mysql://[service-name]:3306/dbname \ --username=$DB_USER \ --password=$DB_PASSWORD \ --changeLogFile=db/changelog/changelog.xml \ updateNode.js / Knex
Section titled “Node.js / Knex”npx knex migrate:latestAutomated backups
Section titled “Automated backups”All plans include daily automated snapshots, plus on-demand snapshots you can take before a risky change. Backups are encrypted at rest and stored separately from your data.
To restore from a snapshot: navigate to your database → Backups → select a snapshot → Restore. You can restore to a new instance without interrupting your live database.
| Plan | Snapshot retention |
|---|---|
| Free | 1 day |
| Starter | 3 days |
| Pro | 7 days |
| Enterprise | 30 days |
Character sets and collations
Section titled “Character sets and collations”New MySQL instances default to utf8mb4 charset with utf8mb4_unicode_ci collation, the correct choice for modern applications that need full Unicode support including emoji.
SHOW VARIABLES LIKE 'character_set%';SHOW VARIABLES LIKE 'collation%';Connecting with common ORMs
Section titled “Connecting with common ORMs”Prisma (MySQL provider)
Section titled “Prisma (MySQL provider)”datasource db { provider = "mysql" url = env("DATABASE_URL")}TypeORM
Section titled “TypeORM”import { DataSource } from 'typeorm'
export const AppDataSource = new DataSource({ type: 'mysql', url: process.env.DATABASE_URL, entities: ['src/entities/**/*.ts'], migrations: ['src/migrations/**/*.ts'],})SQLAlchemy (Python)
Section titled “SQLAlchemy (Python)”from sqlalchemy import create_engine
# Replace mysql:// with mysql+pymysql:// for PyMySQL driverurl = os.environ["DATABASE_URL"].replace("mysql://", "mysql+pymysql://", 1)engine = create_engine(url, pool_pre_ping=True)