Skip to content

MySQL

Managed MySQL with automated backups and private internal networking.

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

From + Service → Databases, add MySQL. Pick version, disk size, and plan.

Attach it from another service’s Variables. DATABASE_URL is injected.

Services in the same environment reach MySQL by service name on the private network. No public exposure.

Connection string (internal)
mysql://user:password@[service-name]:3306/dbname

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.

Connection string (external)
mysql://user:password@db.stackblaze.cloud:3306/dbname?ssl=true

Configure a pre-deploy command under Settings → Deploy → Pre-deploy command to ensure migrations run before new traffic is routed to your service.

Pre-deploy command
npx prisma migrate deploy
Pre-deploy command
flyway -url=jdbc:mysql://[service-name]:3306/dbname \
-user=$DB_USER \
-password=$DB_PASSWORD \
migrate
Pre-deploy command
liquibase \
--url=jdbc:mysql://[service-name]:3306/dbname \
--username=$DB_USER \
--password=$DB_PASSWORD \
--changeLogFile=db/changelog/changelog.xml \
update
Pre-deploy command
npx knex migrate:latest

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

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.

Verify charset
SHOW VARIABLES LIKE 'character_set%';
SHOW VARIABLES LIKE 'collation%';
prisma/schema.prisma
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
data-source.ts
import { DataSource } from 'typeorm'
export const AppDataSource = new DataSource({
type: 'mysql',
url: process.env.DATABASE_URL,
entities: ['src/entities/**/*.ts'],
migrations: ['src/migrations/**/*.ts'],
})
database.py
from sqlalchemy import create_engine
# Replace mysql:// with mysql+pymysql:// for PyMySQL driver
url = os.environ["DATABASE_URL"].replace("mysql://", "mysql+pymysql://", 1)
engine = create_engine(url, pool_pre_ping=True)