MySQL
DocsDatabasesMySQL

MySQL

MySQL-compatible database on StackBlaze, served by MariaDB, with private in-project connectivity. Enable backups and point-in-time recovery from the add-on Backups tab.

Powered by MariaDB

MySQL on StackBlaze is served by MariaDB 11.4, a MySQL-compatible engine. Your MySQL drivers and SQL work unchanged. In the catalog the add-on is named MariaDB.
Adding MySQL from the Databases catalog and attaching it to the app injects MYSQL_HOST, MYSQL_PORT, MYSQL_DATABASE, and MYSQL_PASSWORD.

Creating a MariaDB instance

From the project canvas, click + ServiceDatabasesMariaDB. Stage the add-on, then click Commit.

To attach it to an app, use the add-on's Connections list or the app's Add-ons tab. StackBlaze injects MySQL-style environment variables into the app. There is no Environment tab → Attach database flow. To inspect or add your own variables, use the app's Variables tab.

Injected environment variables

Attached apps receive discrete MYSQL_* variables. StackBlaze does not inject DATABASE_URL for MariaDB.

VariableRole
MYSQL_HOSTInstance hostname
MYSQL_PORT3306
MYSQL_USERDatabase user
MYSQL_PASSWORDPassword
MYSQL_DATABASEDatabase name (when you set one)

If a tool requires a URL, build one from those variables:

Construct a URL from MYSQL_*
mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DATABASE

Browse and query with CloudBeaver

Every database add-on ships with CloudBeaver. Open with DB Beaver on the add-on's Overview starts a scoped session where you can browse tables, run SQL, and edit data in the browser.

Open with DB Beaver launches a scoped CloudBeaver session where the users table is browsed, a query runs, and the results appear.

Running migrations

Run migrations as part of your app's deploy or startup so they finish before the new version serves traffic. Use the injected MYSQL_* variables.

Prisma

Migrate
npx prisma migrate deploy

Flyway

Migrate
flyway -url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DATABASE \
        -user=$MYSQL_USER \
        -password=$MYSQL_PASSWORD \
        migrate

Liquibase

Migrate
liquibase \
  --url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DATABASE \
  --username=$MYSQL_USER \
  --password=$MYSQL_PASSWORD \
  --changeLogFile=db/changelog/changelog.xml \
  update

Node.js / Knex

Migrate
npx knex migrate:latest

Tip

There is no injected DATABASE_URL. Point ORMs and JDBC tools at MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE.

Backups and point-in-time recovery

Backups are not enabled automatically. Open the MariaDB add-on, go to the Backups tab, and click Enable backups. From there you can use Backup now, Restore, and Schedule.

MariaDB supports point-in-time recovery once backups are enabled. Restore always creates a new instance — there is no in-place restore. After the new instance is ready, switch the app connection to it from the add-on Connections list or the app Add-ons tab.

For the full backup workflow, see Backups & recovery.

Character sets and collations

New MariaDB 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%';

Connecting with common ORMs

Prisma (MySQL provider)

Prisma requires a URL. Build one from the injected MYSQL_* variables and expose it as DATABASE_URL in your app if needed.

prisma/schema.prisma
datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

TypeORM

data-source.ts
import { DataSource } from 'typeorm'

export const AppDataSource = new DataSource({
  type: 'mariadb',
  host: process.env.MYSQL_HOST,
  port: Number(process.env.MYSQL_PORT),
  username: process.env.MYSQL_USER,
  password: process.env.MYSQL_PASSWORD,
  database: process.env.MYSQL_DATABASE,
  entities: ['src/entities/**/*.ts'],
  migrations: ['src/migrations/**/*.ts'],
})

SQLAlchemy (Python)

database.py
import os
from sqlalchemy import create_engine

url = (
    f"mysql+pymysql://{os.environ['MYSQL_USER']}:{os.environ['MYSQL_PASSWORD']}"
    f"@{os.environ['MYSQL_HOST']}:{os.environ['MYSQL_PORT']}/{os.environ['MYSQL_DATABASE']}"
)
engine = create_engine(url, pool_pre_ping=True)

Under the hood

The catalog add-on is MariaDB (default image MariaDB 11.4). Attached apps reach it over the project's private network using the injected MYSQL_* variables.