How to Reconfigure 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 update your database engine’s parameters with the API, such as sql_mode and connect_timeout. For a full list of the parameters you can edit, see our API reference. Under the REQUEST BODY SCHEMA section, click config, and then click the mysql option.

To ensure database stability, you can only edit the parameters listed in our API reference. To change other MySQL parameters, contact support.

Update a Database’s Configuration Using the CLI

How to update a database's configuration using the DigitalOcean CLI

To update a database's configuration via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token, and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

                  doctl auth init
                
  4. Finally, update a database's configuration with doctl databases configuration update. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl databases configuration update <db-id> [flags]
                

Update a Database’s Configuration Using the API

How to update a database's configuration using the DigitalOcean API

To update a database's configuration using the DigitalOcean API, follow these steps:

  1. Create a personal access token, and save it for use with the API.

  2. Send a PATCH request to https://api.digitalocean.com/v2/databases/{database_cluster_uuid}/config

    cURL

    To update a database's configuration with cURL, call:

    
                    curl -X PATCH \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"config": {"sql_mode": "ANSI,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES","sql_require_primary_key": true}}' \
      "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/config"

    Python

    
                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    resp = client.databases.patch_config(database_cluster_uuid="a7aba9d")