Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Data Transfer
  • Available transfers
  • Getting started
  • Step-by-step guide
  • Practical guidelines
    • All tutorials
    • Data migration
      • Migrating data between Yandex Managed Service for Apache Kafka® clusters
      • Migrating data to Yandex Managed Service for ClickHouse
      • Migrating data to Yandex Managed Service for Greenplum®
      • Migrating data to Yandex Managed Service for MongoDB
      • Migrating data to Yandex Managed Service for MySQL
      • Migrating data from Yandex Managed Service for MySQL to MySQL
      • Migrating data to Yandex Managed Service for PostgreSQL
    • Data delivery
    • Asynchronous replication of data
    • Saving data streams
  • Concepts
  • Troubleshooting
  • Access management
  • Pricing policy
  • API reference
  • Questions and answers
  1. Practical guidelines
  2. Data migration
  3. Migrating data from Yandex Managed Service for MySQL to MySQL

Delivering data from Yandex Managed Service for MySQL to MySQL

Written by
Yandex Cloud
,
improved by
Dmitry A.
  • Before you begin
  • Transferring data
  • See also

To migrate a database deployed in a Yandex Managed Service for MySQL cluster to a third-party MySQL cluster:

  1. Transfer data.
  2. Disable data writes to the source database.
  3. Switch over the load to a third-party cluster.

Migration across versions is supported. For example, you can move databases from MySQL 5.7 to 8. The MySQL major version on a third-party cluster must be equal to or higher than the version in the Yandex Managed Service for MySQL cluster.

Before you begin

Create a MySQL cluster with any suitable configuration. In this case:

  • The MySQL version must be the same or higher than the version in the source cluster.

    Transferring data with an increase in the MySQL major version is possible, but not guaranteed. For more information, see the MySQL documentation.

    Migration with a MySQL version downgrade is impossible.

  • SQL mode must be the same as in the source cluster.

Transferring data

  1. Prepare the source cluster database.

  2. Prepare the target cluster database.

  3. Set up the endpoints and transfer:

    Manually
    Using Terraform
    1. Create a source endpoint:

      • Database type: MySQL.

      • Connection settings: MDB cluster.

        Specify the source cluster ID.

    2. Create a target endpoint:

      • Database type: MySQL.

      • Connection settings: Custom installation.

        Specify the target cluster connection settings.

    3. Create a transfer of the Snapshot and increment type that will use the created endpoints.

    4. Activate the transfer.

    1. If you don't have Terraform, install it.

    2. Download the file with provider settings. Place it in a separate working directory and specify the parameter values.

    3. Download the transfer and endpoint configuration file called data-transfer-mmy-mysql.tf to the same working directory.

    4. Specify the following in the configuration file:

      • Source endpoint parameters.
      • Target endpoint parameters.
    5. Run the terraform init command in the directory with the configuration files. This command initializes the provider specified in the configuration files and enables you to use the provider resources and data sources.

    6. Make sure the Terraform configuration files are correct using the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

    7. Create the required infrastructure:

      1. Run the command to view planned changes:

        terraform plan
        

        If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.

      2. If you are happy with the planned changes, apply them:

        1. Run the command:

          terraform apply
          
        2. Confirm the update of resources.

        3. Wait for the operation to complete.

      All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console.

      Once created, a transfer is activated automatically.

    Warning

    Avoid any changes to the data schema in the source and target clusters during the transfer operation. For more information, see Working with databases during the transfer.

  4. Wait for the transfer status to change to Replicating.

  5. Switch the source cluster to read-only mode and switch the load to the target cluster.

  6. On the transfer monitoring page, wait for the Maximum lag on delivery, [s] metric to decrease to zero. This means that all changes that occurred in the source cluster after data was copied are transferred to the target cluster.

  7. Deactivate the transfer and wait for its status to change to Stopped.

    For more information about transfer statuses, see Transfer lifecycle.

  8. Delete the endpoints and the transfer you created:

    Manually
    Using Terraform

    If you created your endpoints and transfer manually:

    1. Delete the stopped transfer.
    2. Delete endpoints for the source and target.

    If you used Terraform to create your endpoints and transfer:

    1. In the command line, go to the folder with the current Terraform configuration file with an infrastructure plan.

    2. Delete the data-transfer-mmy-mysql.tf configuration file.

    3. Make sure the Terraform configuration files are correct using the command:

      terraform validate
      

      If there are errors in the configuration files, Terraform will point to them.

    4. Confirm the update of resources.

      1. Run the command to view planned changes:

        terraform plan
        

        If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.

      2. If you are happy with the planned changes, apply them:

        1. Run the command:

          terraform apply
          
        2. Confirm the update of resources.

        3. Wait for the operation to complete.

      All the resources described in the data-transfer-mmy-mysql.tf configuration file will be deleted.

See also

For other migration methods, see the Yandex Managed Service for MySQL documentation.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Before you begin
  • Transferring data
  • See also