How to Configure Custom CNAME Records for MySQL Clusters
Last verified 26 Jun 2026
MySQL is an open source, object-relational database built with speed and reliability in mind. Its large and active developer community has created many third-party applications, tools, and libraries that expand MySQL’s functionality.
You can assign custom CNAME records to DigitalOcean Managed MySQL Standard Edition clusters during cluster and replica creation using the DigitalOcean API.
Custom CNAME records let clients connect using a domain name you control, such as db.example.com, instead of the cluster’s default *.db.ondigitalocean.com hostname. This is useful if you provide database access to end users and want to use your own branding.
Limits
- Custom CNAMEs are available for Standard Edition clusters only. Advanced Edition clusters do not support custom CNAMEs.
- Custom CNAMEs are available through the DigitalOcean API only. There is no Control Panel or
doctlCLI support. - You can only add custom CNAMEs when creating a cluster or replica. They can’t be added to or updated on existing clusters or replicas.
- Each cluster supports a maximum of 16 custom CNAMEs.
- Each CNAME must be a valid RFC 1123 hostname (for example,
db.example.com). - Each CNAME can be up to 253 characters long.
Configure Custom CNAMEs at Cluster Creation
To assign custom CNAMEs when creating a database cluster, include the do_settings object with a service_cnames array in the request body of the create database cluster API call.
The following example creates a cluster with two custom CNAMEs:
{
"name": "db-example",
"engine": "<engine>",
"version": "<version>",
"region": "nyc3",
"size": "db-s-1vcpu-1gb",
"num_nodes": 1,
"do_settings": {
"service_cnames": [
"db.example.com",
"database.example.com"
]
}
}Send the request using curl:
curl -X POST "https://api.digitalocean.com/v2/databases" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{
"name": "db-example",
"engine": "<engine>",
"version": "<version>",
"region": "nyc3",
"size": "db-s-1vcpu-1gb",
"num_nodes": 1,
"do_settings": {
"service_cnames": [
"db.example.com",
"database.example.com"
]
}
}'Replace <engine> with the database engine (for example, pg, mysql, or valkey) and <version> with the engine version.
The response includes the do_settings object with the custom CNAMEs you configured.
Configure Custom CNAMEs for Read Replicas
You can also assign custom CNAMEs when creating a read replica. Include the do_settings object in the request body of the create read replica API call:
curl -X POST "https://api.digitalocean.com/v2/databases/<your-cluster-uuid>/replicas" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{
"name": "db-replica-example",
"size": "db-s-1vcpu-1gb",
"do_settings": {
"service_cnames": [
"db-replica.example.com"
]
}
}'Set Up DNS Records
After you create a cluster with custom CNAMEs, configure DNS records with your DNS provider to point each CNAME to the cluster’s default hostname. Create a CNAME record for each custom domain that resolves to the cluster’s *.db.ondigitalocean.com hostname.
For example, if your cluster’s default hostname is db-example-do-user-1234567-0.db.ondigitalocean.com, create a DNS record like:
db.example.com. CNAME db-example-do-user-1234567-0.db.ondigitalocean.com.