# How to Resize 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. You can resize existing MySQL database clusters at any time to add more CPUs, RAM, and storage. To avoid data loss, you cannot decrease the size of database clusters. ## Resize a Database Cluster Using the CLI To resize a database cluster using `doctl`, you need to provide a value for the `--size` flag, which specifies the cluster’s new configuration (number of CPUs, amount of RAM, and hard disk space). Use the [`doctl databases options slugs`](https://docs.digitalocean.com/reference/doctl/reference/databases/options/slugs/index.html.md) command to get a list of available values. ## How to Resize a Database Cluster 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 resize`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/databases/resize/index.html.md) for more details: ```shell doctl databases resize [flags] ``` The following example resizes a PostgreSQL or MySQL database to have two nodes, 16 vCPUs, 64 GB of memory, and 2048 GiB of storage space: ```shell doctl databases resize ca9f591d-9999-5555-a0ef-1c02d1d1e352 --num-nodes 2 --size db-s-16vcpu-64gb --storage-size-mib 2048000 --wait true ``` ## Resize a Database Cluster Using the API To resize a database cluster using the API, you need to provide a value for the `size` field, which specifies the cluster’s configuration (number of CPUs, amount of RAM, and hard disk space). Use the [`/v2/databases/options`](https://docs.digitalocean.com/reference/api/digitalocean/index.html.md#operation/databases_list_options) endpoint to get a list of available values. ## How to Resize a Database Cluster 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}/resize`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/databases_update_clusterSize). ### cURL Using cURL: ```shell curl -X PUT \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{"size":"db-s-4vcpu-8gb", "num_nodes":3, "storage_size_mib":163840}' \ "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/resize" ``` ### Go Using [Godo](https://github.com/digitalocean/godo), the official DigitalOcean API client for Go: ```go import ( "context" "github.com/digitalocean/godo" ) func main() { pat := "mytoken" client := godo.NewFromToken(pat) ctx := context.TODO() resizeRequest := &godo.DatabaseResizeRequest{ SizeSlug: "db-s-4vcpu-8gb", NumNodes: 3, StorageSizeMib: 163840, } } ``` ### 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 = { "size": "db-s-4vcpu-8gb", "num_nodes": 3, "storage_size_mib": 163840 } update_resp = client.databases.update_cluster_size(database_cluster_uuid="a7a8bas", body=req) ``` ## Resize a Database Cluster Using the Control Panel To resize a MySQL database cluster, click the name of the cluster in the control panel to go to its **Overview** page, then click the **Settings** tab. In the **Cluster configuration** section, click **Edit**. Select your cluster configuration and CPU option. ![Cluster configuration section with additional nodes selected](https://docs.digitalocean.com/screenshots/databases/mysql-cluster-configuration.27c26fbadb592cf91f6b79713281fdab2956faa9884679677b42ecd19b0cab75.png) Then, select your storage size. ![](https://docs.digitalocean.com/screenshots/databases/dbaas-choose-storage-size.3f7414c89a29f123c45ba0f1c4350ee6b2264c6d810faa1fba245f8ed3f3a7a0.png) The **Autoscale storage** section lets you check a box to automatically increase storage when disk capacity reaches a set percentage threshold. The system bills this increase as [additional storage](https://docs.digitalocean.com/products/databases/mysql/details/pricing/index.html.md). If you click **Customize**, you can type your own percentage threshold and storage increment. Autoscaling takes several minutes, depending on the cluster size. It runs without downtime, and you do not need to take any action. ![The storage autoscaling section](https://docs.digitalocean.com/screenshots/databases/storage-autoscaling.6d5c7dd5a6f82be81b30a1a473c89daaf982b4de7e4424a1d9f1e61a8e62b952.png) Once you have selected your new configuration and size, click **Save** to provision the new configuration. The provisioning takes several minutes but the total time depends on the size of the cluster. Your cluster’s state changes from **Active** to **Resizing** until the process is done. You can expect no downtime and do not need to take action.