Appearance
MySQL
MySQL 8.0 with optional primary-replica replication, automated backups, and slow query logging.
Configuration
yaml
services:
db:
package: mysql
config:
root_password: "${MYSQL_ROOT_PASSWORD}"
replication_password: "${MYSQL_REPL_PASSWORD}"To add read replicas:
yaml
services:
db:
package: mysql
replicas: 2
config:
root_password: "${MYSQL_ROOT_PASSWORD}"
replication_password: "${MYSQL_REPL_PASSWORD}"Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
root_password | Yes | Root password for the MySQL server | |
replication_password | Yes | Password for the replication user | |
replicas | No | 0 | Number of read replicas |
dedicated_server | No | true | Let MySQL auto-tune memory and I/O for the full server (innodb_dedicated_server) |
max_connections | No | 151 | Maximum concurrent connections |
slow_query_log | No | true | Enable the slow query log |
long_query_time | No | 5 | Queries slower than this (seconds) are logged |
log_queries_not_using_indexes | No | true | Log queries that don't use indexes |
keep_daily_backups | No | 5 | Number of daily full backups to retain |
keep_weekly_backups | No | 1 | Number of weekly backups to retain |
keep_monthly_backups | No | 1 | Number of monthly backups to retain |
Replication
When replicas is set, managed creates a primary-replica topology:
- Primary, handles all writes, streams binary logs to replicas
- Replicas, read-only copies that follow the primary via GTID-based replication over TLS
Replication uses caching_sha2_password authentication and requires SSL. The primary's auto-generated CA certificate is shared with replicas through managed state.
Checking replication health
bash
managed service db check-replicationPromoting a replica
If the primary fails, you can promote a replica:
bash
managed service db promoteBackups
Full backups run every 6 hours via mysqldump with --single-transaction, compressed with gzip and uploaded to object storage. Binary log backups run every 15 minutes for point-in-time recovery.
Retention policy
Backups follow a daily/weekly/monthly retention scheme:
- Daily: keep the most recent backup per calendar day (default: 5 days)
- Weekly: keep the oldest daily per ISO week (default: 1 week)
- Monthly: keep the oldest daily per calendar month (default: 1 month)
Binary log backups older than the oldest retained full backup are automatically cleaned up.
Manual backup
bash
managed service db backupList backups
bash
managed service db backup-listRestore from backup
bash
managed service db restore --arg confirm=yesCommands
| Command | Description |
|---|---|
managed service <name> check-replication | Check replication health and lag |
managed service <name> backup | Create a full backup now |
managed service <name> backup-list | List available backups in storage |
managed service <name> restore | Restore from the latest (or specified) backup |
managed service <name> promote | Promote a replica to primary |
Connection
MySQL listens on port 3306, open to public by default. The easiest way in:
bash
managed repl <service-name>It opens the mysql client with the password passed through the environment — never on a command line. To connect manually, -p (with no value) makes the client prompt for the password; don't type it into the command itself:
bash
mysql -u root -p -h <server-ip> -P 3306How it works
The service installs MySQL 8.0 from the default Ubuntu repositories. The primary is configured with:
- Binary logging (ROW format) and GTID for replication
skip-name-resolveandlocal-infile = 0for securityinnodb_dedicated_server = ONby default (auto-sizes buffer pool, redo log, flush method based on available RAM)- Slow query log with configurable thresholds
- Log rotation for error and slow query logs
Where the data lives
MySQL keeps all its data in /var/lib/mysql on the server. managed installs MySQL onto whatever disk and RAID layout the server already has, it never repartitions or sets up RAID for you.
On a cloud server that's taken care of automatically. On an OVH bare-metal server you set the disk layout up yourself, once, before the first install, so your data lands on a redundant array with room to grow. Follow Storage & RAID on OVH bare metal before you run managed apply on one of those boxes.