$npx -y skills add digitalocean-labs/do-app-platform-skills --skill managed-db-servicesConfigure DigitalOcean Managed MySQL, MongoDB, Valkey, Kafka, and OpenSearch for App Platform. Use when setting up non-PostgreSQL databases, configuring trusted sources, or troubleshooting database connectivity.
| 1 | # Managed Database Services Skill |
| 2 | |
| 3 | Configure DigitalOcean Managed MySQL, MongoDB, Valkey (Redis), Kafka, and OpenSearch for App Platform applications. |
| 4 | |
| 5 | ## Quick Decision |
| 6 | |
| 7 | ``` |
| 8 | Which database engine? |
| 9 | ├── PostgreSQL → Use the postgres skill instead |
| 10 | ├── MySQL → See reference/mysql.md |
| 11 | ├── MongoDB → See reference/mongodb.md |
| 12 | ├── Valkey/Redis → See reference/valkey.md |
| 13 | ├── Kafka → See reference/kafka.md (⚠️ trusted sources limitations) |
| 14 | └── OpenSearch → See reference/opensearch.md |
| 15 | ``` |
| 16 | |
| 17 | > **Tip**: For complex multi-step deployments, use the **planner** skill. For an overview of all skills, see [root SKILL.md](../../SKILL.md). |
| 18 | |
| 19 | --- |
| 20 | |
| 21 | ## Critical Constraints |
| 22 | |
| 23 | | Constraint | Impact | |
| 24 | |------------|--------| |
| 25 | | Dev databases | PostgreSQL only — MySQL/MongoDB/Kafka/OpenSearch require `production: true` | |
| 26 | | Build-time DB access | ❌ Trusted sources block build phase — use PRE_DEPLOY job for migrations | |
| 27 | | Kafka trusted sources | IP-based only (`ip_addr:`); app-based (`app:`) NOT supported | |
| 28 | | OpenSearch logging | ❌ NOT supported with trusted sources enabled | |
| 29 | | MongoDB db_name | Cannot contain capital letters in app spec | |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## Trusted Sources Quick Reference |
| 34 | |
| 35 | | Network Mode | Rule Type | Supported Engines | |
| 36 | |--------------|-----------|-------------------| |
| 37 | | Public | `app:$APP_ID` | MySQL, MongoDB, Valkey, OpenSearch | |
| 38 | | Public | `app:$APP_ID` | ❌ Kafka (not supported) | |
| 39 | | VPC | `ip_addr:<vpc-cidr>` | All engines | |
| 40 | | VPC | `app:$APP_ID` | ❌ None (app rules whitelist public IP only) | |
| 41 | |
| 42 | > **VPC deployments**: Use VPC CIDR (`ip_addr:10.126.0.0/20`) — simpler than per-app IPs. |
| 43 | > |
| 44 | > See [networking skill - Trusted Sources](../networking/SKILL.md#trusted-sources-the-big-picture) for complete configuration. |
| 45 | |
| 46 | --- |
| 47 | |
| 48 | ## Bindable Variables (All Engines) |
| 49 | |
| 50 | ```yaml |
| 51 | databases: |
| 52 | - name: db # Component name (used in ${db.VAR_NAME}) |
| 53 | engine: <ENGINE> # MYSQL, MONGODB, REDIS, KAFKA, OPENSEARCH |
| 54 | production: true # REQUIRED for bindable variables |
| 55 | cluster_name: my-cluster # Must match existing cluster name |
| 56 | db_name: myappdb # Database within cluster (where applicable) |
| 57 | db_user: myappuser # User created via doctl |
| 58 | ``` |
| 59 | |
| 60 | | Variable | Description | |
| 61 | |----------|-------------| |
| 62 | | `${db.DATABASE_URL}` | Full connection string (PUBLIC hostname only!) | |
| 63 | | `${db.HOSTNAME}` | Database host (PUBLIC hostname only!) | |
| 64 | | `${db.PORT}` | Database port | |
| 65 | | `${db.USERNAME}` | Database user | |
| 66 | | `${db.PASSWORD}` | Database password (auto-populated) | |
| 67 | | `${db.DATABASE}` | Database name | |
| 68 | | `${db.CA_CERT}` | CA certificate for TLS | |
| 69 | |
| 70 | > **VPC Note**: Bindable variables return PUBLIC hostnames even with VPC enabled. For private endpoints, add separate `*_PRIVATE_*` environment variables with hardcoded private hostnames. |
| 71 | |
| 72 | --- |
| 73 | |
| 74 | ## Engine Quick Reference |
| 75 | |
| 76 | | Engine | App Spec | Port | Protocol | Key Notes | |
| 77 | |--------|----------|------|----------|-----------| |
| 78 | | MySQL | `MYSQL` | 25060 | `mysql://...?ssl-mode=REQUIRED` | [Full guide](reference/mysql.md) | |
| 79 | | MongoDB | `MONGODB` | 27017 | `mongodb+srv://...?tls=true&authSource=admin` | [Full guide](reference/mongodb.md) | |
| 80 | | Valkey | `REDIS` | 25061 | `rediss://` (with SSL) | [Full guide](reference/valkey.md) | |
| 81 | | Kafka | `KAFKA` | 9093 | SASL/SCRAM-SHA-256 | [Full guide](reference/kafka.md) | |
| 82 | | OpenSearch | `OPENSEARCH` | 25060 | `https://` with basic auth | [Full guide](reference/opensearch.md) | |
| 83 | |
| 84 | --- |
| 85 | |
| 86 | ## Quick Start: MySQL |
| 87 | |
| 88 | ```bash |
| 89 | # 1. Create cluster + user |
| 90 | doctl databases create my-mysql --engine mysql --region nyc3 --size db-s-1vcpu-2gb --version 8 |
| 91 | CLUSTER_ID=$(doctl databases list --format ID,Name --no-header | grep my-mysql | awk '{print $1}') |
| 92 | doctl databases db create $CLUSTER_ID myappdb |
| 93 | doctl databases user create $CLUSTER_ID myappuser |
| 94 | |
| 95 | # 2. Add to trusted sources |
| 96 | APP_ID=$(doctl apps list --format ID,Spec.Name --no-header | grep my-app | awk '{print $1}') |
| 97 | doctl databases firewalls append $CLUSTER_ID --rule app:$APP_ID |
| 98 | |
| 99 | # 3. Reference in app spec |
| 100 | ``` |
| 101 | |
| 102 | ```yaml |
| 103 | databases: |
| 104 | - name: db |
| 105 | engine: MYSQL |
| 106 | production: true |
| 107 | cluster_name: my-mysql |
| 108 | db_name: myappdb |
| 109 | db_user: myappuser |
| 110 | |
| 111 | services: |
| 112 | - name: api |
| 113 | envs: |
| 114 | - key: DATABASE_URL |
| 115 | scope: RUN_TIME |
| 116 | value: ${db.DATABASE_URL} |
| 117 | ``` |
| 118 | |
| 119 | **Full guide**: See [mysql.md](reference/mysql.md) |
| 120 | |
| 121 | --- |
| 122 | |
| 123 | ## Quick Start: MongoDB |
| 124 | |
| 125 | ```bash |
| 126 | doctl databases create my-mongo --engine mongodb --region nyc3 --size db-s-1vcpu-2gb --version 7 |
| 127 | CLUSTER_ID=$(doctl databases list --format ID,Name --no-header | grep my-mongo | awk '{print $1}') |
| 128 | doctl databases user create $CLUSTER_ID myappuser |
| 129 | doctl dat |