Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for MySQL®
  • Getting started
    • All guides
      • Connecting to a database
      • SQL queries in Yandex WebSQL
      • Database management
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database
  • Setting SQL mode
  • Changing a character set and collation rules
  1. Step-by-step guides
  2. Databases
  3. Database management

Managing databases in Managed Service for MySQL®

Written by
Yandex Cloud
Updated at December 17, 2025
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database
  • Setting SQL mode
  • Changing a character set and collation rules

You can add and remove databases, view database details, and manage some database settings using Managed Service for MySQL® interfaces.

Warning

You cannot manage databases using SQL commands. However, you can run ALTER DATABASE.

Getting a list of cluster databasesGetting a list of cluster databases

Management console
CLI
REST API
gRPC API
  1. Go to Managed Service for MySQL.
  2. Click the cluster name and select the Databases tab.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To get a list of cluster databases, run this command:

yc managed-mysql database list \
   --cluster-name=<cluster_name>

You can get the cluster name with the list of clusters in the folder.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Database.list method, e.g., via the following cURL request:

    curl \
      --request GET \
      --header "Authorization: Bearer $IAM_TOKEN" \
      --url 'https://mdb.api.cloud.yandex.net/managed-mysql/v1/clusters/<cluster_ID>/databases'
    

    You can get the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure your request was successful.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Call the DatabaseService/List method, e.g., via the following gRPCurl request:

    grpcurl \
      -format json \
      -import-path ~/cloudapi/ \
      -import-path ~/cloudapi/third_party/googleapis/ \
      -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/database_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "cluster_id": "<cluster_ID>"
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.mysql.v1.DatabaseService.List
    

    You can get the cluster ID with the list of clusters in the folder.

  4. Check the server response to make sure your request was successful.

Creating a databaseCreating a database

Note

You can create a maximum of 1000 databases in each cluster.

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to Managed Service for MySQL.

  2. Click the cluster name.

  3. If you want a new user to become the database owner, create it.

  4. Select the Databases tab.

  5. Click Create database.

  6. Enter a database name and click Create.

    The database name may contain Latin letters, numbers, hyphens, and underscores. It may be up to 63 characters long. Such names as mysql, sys, information_schema, and performance_schema are reserved for internal use by Managed Service for MySQL®. You cannot create databases with these names.

  7. Grant access privileges for the created database to the relevant cluster users.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To create a database in a cluster:

  1. See the description of the CLI command for creating a database:

     yc managed-mysql database create --help
    
  2. Run this command:

    yc managed-mysql database create <DB_name> --cluster-name=<cluster_name>
    

    The database name may contain Latin letters, numbers, hyphens, and underscores. It may be up to 63 characters long. Such names as mysql, sys, information_schema, and performance_schema are reserved for internal use by Managed Service for MySQL®. You cannot create databases with these names.

    You can get the cluster name with the list of clusters in the folder.

    Managed Service for MySQL® will start creating the database.

  1. Open the current Terraform configuration file describing your infrastructure.

    For information on how to create such a file, see Creating a cluster.

  2. Add the yandex_mdb_mysql_database resource:

    resource "yandex_mdb_mysql_database" "<DB_name>" {
      cluster_id = "<cluster_ID>"
      name       = "<DB_name>"
    }
    

    The database name may contain Latin letters, numbers, hyphens, and underscores. It may be up to 63 characters long. Such names as mysql, sys, information_schema, and performance_schema are reserved for internal use by Managed Service for MySQL®. You cannot create databases with these names.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see this Terraform provider article.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Database.create method, e.g., via the following cURL request:

    curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mysql/v1/clusters/<cluster_ID>/databases' \
        --data '{
                  "databaseSpec": {
                    "name": "<DB_name>"
                  }
                }'
    

    The database name may contain Latin letters, numbers, hyphens, and underscores. It may be up to 63 characters long. Such names as mysql, sys, information_schema, and performance_schema are reserved for internal use by Managed Service for MySQL®. You cannot create databases with these names.

    You can get the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure your request was successful.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Call the DatabaseService/Create method, e.g., via the following gRPCurl request:

    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/database_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "database_spec": {
                "name": "<DB_name>"
              }
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mysql.v1.DatabaseService.Create
    

    The database name may contain Latin letters, numbers, hyphens, and underscores. It may be up to 63 characters long. Such names as mysql, sys, information_schema, and performance_schema are reserved for internal use by Managed Service for MySQL®. You cannot create databases with these names.

    You can get the cluster ID with the list of clusters in the folder.

  4. Check the server response to make sure your request was successful.

Deleting a databaseDeleting a database

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to Managed Service for MySQL.
  2. Click the cluster name and select the Databases tab.
  3. Click in the row with the database in question and select Delete.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To delete a database, run this command:

 yc managed-mysql database delete <DB_name> --cluster-name=<cluster_name>

You can get the cluster name with the list of clusters in the folder.

  1. Open the current Terraform configuration file describing your infrastructure.

    For information on how to create such a file, see Creating a cluster.

  2. Delete the yandex_mdb_mysql_database resource with the name of the database you are deleting.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see this Terraform provider article.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Database.delete method, e.g., via the following cURL request:

    curl \
        --request DELETE \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mysql/v1/clusters/<cluster_ID>/databases/<DB_name>'
    

    You can get the cluster ID with the list of clusters in the folder, and the database name, with the list of databases in the cluster.

  3. View the server response to make sure your request was successful.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Call the DatabaseService/Delete method, e.g., via the following gRPCurl request:

    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/database_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "database_name": "<DB_name>"
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mysql.v1.DatabaseService.Delete
    

    You can get the cluster ID with the list of clusters in the folder, and the database name, with the list of databases in the cluster.

  4. Check the server response to make sure your request was successful.

Warning

Before creating a new database with the same name, wait for the delete operation to complete. Otherwise, the original database will be restored. You can get the operation status with the list of cluster operations.

Setting SQL modeSetting SQL mode

You can set or update the sql_mode parameter that defines the SQL mode for the database. This will restarts the cluster hosts.

Management console
CLI
Terraform
REST API
gRPC API
  1. Go to Managed Service for MySQL.
  2. Select your cluster and click Edit in the top panel.
  3. Under DBMS settings, click Settings.
  4. In the list of the settings, locate sql_mode.
  5. Select the required SQL modes from the drop-down list. To restore the default settings, click Reset.
  6. Click Save in the DBMS settings dialog box.
  7. Click Save changes.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

Specify the required SQL modes in the --set parameter:

yc managed-mysql cluster update-config \
  --name <cluster_name> \
  --set '"sql_mode=NO_KEY_OPTIONS,NO_TABLE_OPTIONS"'

Pay attention to quotation marks: the parameter value must include the entire string, including sql_mode=.

You can get the cluster name with the list of clusters in the folder.

  1. Open the current Terraform configuration file describing your infrastructure.

    To learn how to create this file, see Creating a cluster.

  2. Specify the required SQL modes in the sql_mode parameter under mysql_config:

    resource "yandex_mdb_mysql_cluster" "<cluster_name>" {
      ...
      mysql_config = {
        sql_mode = "<SQL_mode_list>"
        ...
      }
    }
    
  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see this Terraform provider article.

Timeouts

The Terraform provider sets the following timeouts for Managed Service for MySQL® cluster operations:

  • Creating a cluster, including by restoring it from a backup: 15 minutes.
  • Updating a cluster, including the MySQL® version update: 60 minutes.
  • Deleting a cluster: 15 minutes.

Operations exceeding the timeout are aborted.

How do I change these limits?

Add the timeouts section to the cluster description, such as the following:

resource "yandex_mdb_mysql_cluster" "<cluster_name>" {
  ...
  timeouts {
    create = "1h30m" # 1 hour 30 minutes
    update = "2h"    # 2 hours
    delete = "30m"   # 30 minutes
  }
}
  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Cluster.update method, e.g., via the following cURL request:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

    curl \
        --request PATCH \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-mysql/v1/clusters/<cluster_ID>' \
        --data '{
                  "updateMask": "configSpec.mysqlConfig_<MySQL®_version>",
                  "configSpec": {
                    "mysqlConfig_<MySQL®_version>": {
                      "sqlMode": [
                        "<SQL_mode_1>", "<SQL_mode_2>", ..., "<SQL_mode_N>"
                      ]
                    }
                  }
                }'
    

    Where:

    • updateMask: Comma-separated list of settings you want to update.

      Here, we provide only one setting.

    • configSpec.mysqlConfig_<MySQL®_version>.sqlMode: List of SQL modes. For all available modes, see the following MySQL® docs:

      • Version 5.7
      • Version 8.0

    You can get the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure your request was successful.

  1. Get an IAM token for API authentication and set it as an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Call the ClusterService/Update method, e.g., via the following gRPCurl request:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the update_mask parameter as an array of paths[] strings.

    Format for listing settings
    "update_mask": {
        "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
        ]
    }
    
    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/mysql/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "update_mask": {
                "paths": [
                  "config_spec.mysql_config_<MySQL®_version>"
                ]
              },
              "config_spec": {
                "mysql_config_<MySQL®_version>": {
                  "sql_mode": [
                    "<SQL_mode_1>", "<SQL_mode_2>", ..., "<SQL_mode_N>"
                  ]
                }
              }
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.mysql.v1.ClusterService.Update
    

    Where:

    • update_mask: List of settings you want to update as an array of strings (paths[]).

      Here, we provide only one setting.

    • config_spec.mysql_config_<MySQL®_version>.sql_mode: List of SQL modes. For all available modes, see the following MySQL® docs:

      • Version 5.7
      • Version 8.0

    You can get the cluster ID with the list of clusters in the folder.

  4. Check the server response to make sure your request was successful.

Changing a character set and collation rulesChanging a character set and collation rules

To configure the CHARACTER SET and COLLATE database settings:

  1. Connect to the database as the database owner or as a user with the ALTER privilege for this database.

  2. Run the ALTER DATABASE query:

    ALTER DATABASE <DB_name> CHARACTER SET = 'utf8mb4' COLLATE = 'utf8mb4_unicode_ci';
    
  3. To apply the updated settings not only to the database but also to its tables, convert the tables using the same settings:

    ALTER TABLE <DB_name>.<table_name> CONVERT TO CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
    

Was the article helpful?

Previous
SQL queries in Yandex WebSQL
Next
User management
© 2025 Direct Cursus Technology L.L.C.