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
Creating a MariaDB instance
From the project canvas, click + Service → Databases → MariaDB. 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.
| Variable | Role |
|---|---|
| MYSQL_HOST | Instance hostname |
| MYSQL_PORT | 3306 |
| MYSQL_USER | Database user |
| MYSQL_PASSWORD | Password |
| MYSQL_DATABASE | Database name (when you set one) |
If a tool requires a URL, build one from those variables:
mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DATABASEBrowse 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.
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
npx prisma migrate deployFlyway
flyway -url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DATABASE \
-user=$MYSQL_USER \
-password=$MYSQL_PASSWORD \
migrateLiquibase
liquibase \
--url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DATABASE \
--username=$MYSQL_USER \
--password=$MYSQL_PASSWORD \
--changeLogFile=db/changelog/changelog.xml \
updateNode.js / Knex
npx knex migrate:latestTip
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.
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.
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}TypeORM
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)
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
MYSQL_* variables.