MySQL Migration

Migrate your MySQL server database to our managed MySQL service. Two methods are supported: the replication method and the dump method.

Replication

The replication method is preferred for production databases because it allows for the migration of data with minimal downtime.

First, the process will do a mysqldump to seed the schema and bulk-copy the data. If the preconditions are met for ongoing replication, then it will configure MySQL as a replica of the external database.

Prerequisites

  • The source server needs to be publicly available. You should be able to connect to your target database from the source using MySQL commands.

NOTE
You may rely on Exoscale IP ranges for your firewall restrictions.

  • A MySQL user on the source server with sufficient privileges to perform replication.
CREATE USER 'migration_user'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'migration_user'@'%' WITH GRANT OPTION;

NOTE
Save username and password of your replication user for later.

  • GTID is enabled on the source database.

The global transaction identifier is a unique identifier created and associated with each transaction committed on the server of origin. It allows the continuously generated data to migrate on the sources that are not included in the initial dump.

To review the current GTID setting, run the following command on the source cluster:

show global variables like 'gtid_mode';

Refer to Enabling GTID Transactions Online on the MySQL documentation.

  • The source database version should be between 5.7 and 8.0
  • All databases use the InnoDB engine
  • server_id on the source and the target must not overlap. If they do, update your MySQL configuration file and set server-id to a different number. Then restart your service.

Dump

The source database should not be used while migrating using the dump method, otherwise data will be inconsistent.

Prerequisites

  • The source server needs to be publicly available.
  • A MySQL user on the source server with sufficient privileges to perform migration.

Performing mMgration

The tool used for migration depends on whether the migration happens during service creation or after.

Migration During MySQL Service Creation

You can either use the Portal or the CLI for migration.

First, you need to specify the name of your managed MySQL and add the appropriate IP Filter:

MySQL DBaaS creation

Enable migration by checking the checkbox under the Migrate from existing DB header. Provide the required parameters:

MySQL DBaaS migration

Migration After MySQL Service Creation

If you want to migrate your MySQL database after a managed MySQL service creation, use the Exoscale CLI

NOTE
Use CLI version 1.53.0 or higher.

$ exo dbaas update --mysql-migration-dbname to_migrate --mysql-migration-host 89.145.160.149 --mysql-migration-method replication --mysql-migration-password password --mysql-migration-username migration_user --mysql-migration-port 3306 my-managed-mysql

To check status of our migration we can run command:

$ exo dbaas migration status my-managed-mysql

And if we want to stop the running migration:

$ exo dbaas migration stop my-managed-mysql