# How to Schedule Automatic Software Updates for MySQL Database Clusters 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. DigitalOcean fully manages database software updates for database clusters on your behalf. During the update process, we create a new cluster with OS-level or `db_engine` updates applied, replicate the existing cluster’s data, and then update DNS (which changes the cluster’s underlying IP address). There is no downtime associated with these updates, but there may be brief periods of latency during the maintenance window. Updates are necessary for security and stability, so you can’t disable them, but you can customize the maintenance window or manually initiate an available update. ## Set a Maintenance Window Using the CLI ## How to Set a Maintenance Window Using the DigitalOcean CLI 1. [Install `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl databases maintenance-window update`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/databases/maintenance-window/update/index.html.md) for more details: ```shell doctl databases maintenance-window update [flags] ``` The following example updates the maintenance window for a database cluster with the ID `ca9f591d-f38h-5555-a0ef-1c02d1d1e35`: ```shell doctl databases maintenance-window update ca9f591d-f38h-5555-a0ef-1c02d1d1e35 --day tuesday --hour 16:00 ``` ## Set a Maintenance Window Using the API ## How to Set a Maintenance Window Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a PUT request to [`https://api.digitalocean.com/v2/databases/{database_cluster_uuid}/maintenance`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/databases_update_maintenanceWindow). ### cURL Using cURL: ```shell curl -X PUT \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{"day": "tuesday", "hour": "14:00"}' \ "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/maintenance" ``` ### Go Using [Godo](https://github.com/digitalocean/godo), the official DigitalOcean API client for Go: ```go import ( "context" "os" "github.com/digitalocean/godo" ) func main() { token := os.Getenv("DIGITALOCEAN_TOKEN") client := godo.NewFromToken(token) ctx := context.TODO() maintenanceRequest := &godo.DatabaseUpdateMaintenanceRequest{ Day: "thursday", Hour: "16:00", } _, err := client.Databases.UpdateMaintenance(ctx, "88055188-9e54-4f21-ab11-8a918ed79ee2", maintenanceRequest) } ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) req = { "day": "tuesday", "hour": "14:00" } update_resp = client.databases.update_maintenance_window(database_cluster_uuid="a7a8bas", body=req) ``` ## Set a Maintenance Window Using the Control Panel **Note**: The maintenance window for a cluster applies to its primary node and any standby nodes. Each read-only node has its own maintenance window that is independent of the cluster and other read-only nodes. You can view or edit a cluster or read-only node’s current maintenance window from its **Settings** page, in the **Maintenance Window** section. ![Screenshot of cluster settings page](https://docs.digitalocean.com/screenshots/databases/generic-cluster-settings.a7c5acfcf3078021df22347b3d28813722197b6ddf68b6ade6f1487d3ff74feb.png) Software updates may begin at any time in the 4-hour period after the maintenance window’s start time. For example, a maintenance window defined for Sundays at 7 PM will have updates at any time between 7 PM and 11 PM. To change a cluster or read-only node’s maintenance window, click **Edit**. ![Screenshot of maintenance scheduler window](https://docs.digitalocean.com/screenshots/databases/maintenance-window.be88476517219da1f64585dfbad9995547840fb6395c10053c9188a73c3fab19.png) Choose the day of the week and the start time for the 4-hour maintenance window, then click **Save**. ## Update Manually When new updates are available, cluster and read-only node **Overview** pages have a banner with basic information on the update. ![The maintenance banner on a database overview page](https://docs.digitalocean.com/screenshots/databases/maintenance-banner.c3ab284b8816b43d450ec53dd75a7f9a21a07d418c7e415842b4d99c60c9ccd0.png) Click **Update Now** to open the **Required maintenance** window. This window specifies when the updates will be automatically applied. ![The Required maintenance window with the Start Maintenance button visible](https://docs.digitalocean.com/screenshots/databases/required-maintenance-window.73c5cc5b38656c51d4ba6fabf233ac1c610e42747e1fa86aa1747bb5b4440f69.png) If you want to initiate the update immediately ahead of the scheduled maintenance window, click the **Start Maintenance** button. To manually update read-only nodes, you need to repeat this process for each individual node.