This page describes how to migrate your databases to a new Cloud SQL instance that Database Migration Service creates on your behalf when you configure the migration job. If your migration has different requirements, consider following a different migration flow. For more information, See Guide: Migrate to an existing Cloud SQL instance.
At a high level, the migration follows these steps:
- Configure the source database to allow Database Migration Service to move your data to the new databases.
- Create the connection profile and the migration job.
- Depending on your connectivity configuration, you might need to adjust the firewall settings.
- Start and monitor the migration job.
- Promote the migration job and move your application to use the new databases.
Costs
In this document, you use the following billable components of Google Cloud:
- Cloud SQL (See Cloud SQL pricing.)
- If used for storing Customer-managed Encryption Keys (CMEK): Cloud Storage (See Cloud Storage pricing.)
To generate a cost estimate based on your projected usage, use the pricing calculator.
Before you begin
- Verify if this migration path can fully support your scenario.
See the following pages:
- Supported sources and destinations on the Scenario overview page lists all supported source and destination versions.
- Known limitations describes supported data types, database sizes, and other limitations.
-
Different network connectivity methods are available for different source databases. Consider and plan your network connectivity before you begin the migration procedures. For more information, see Networking overview.
Migrating to a new destination instance doesn't support Private Service Connect interfaces connectivity. If you want to use Private Service Connect interfaces connectivity, consider pre-creating your destination instance directly in Cloud SQL. See Guide: Migrate to an existing Cloud SQL instance.
- For one-time migrations: Consider the schedule for your migration. One-time migrations perform only a full dump and load operation without subsequent change data capture. We recommend that you disable writes on your source database for the migration process to avoid losing data.
- Consider in which region you want to create the destination database. Database Migration Service is a fully-regional product, meaning all entities related to your migration (source and destination connection profiles, migration jobs, destination databases, conversion workspaces) must be saved in a single region.
- In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
- Enable the Database Migration Service and Cloud SQL Admin APIs.
Required roles
To get the permissions that you need to perform homogeneous MySQL migrations with Database Migration Service, ask your administrator to grant you the required IAM roles on your project:
-
Database Migration Admin (
roles/datamigration.admin) -
Cloud SQL Admin (
roles/cloudsql.admin)
For more information about granting roles, see Manage access in the Identity and Access Management documentation.
These predefined roles contain the permissions required to perform homogeneous MySQL migrations with Database Migration Service. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to perform homogeneous MySQL migrations with Database Migration Service:
datamigration.*cloudsql.instances.createcloudsql.instances.getcloudsql.instances.listcloudsql.instances.updatecloudsql.instances.deletecloudsql.operations.getcloudsql.users.listcloudsql.users.getcloudsql.users.createcloudsql.users.updatecloudsql.users.delete
You might also be able to get these permissions with custom roles or other predefined roles.
Prepare your source database
To prepare your source data for migration, follow these steps:
- Consider if you want to provide your own dump files or have Database Migration Service
perform the full dump automatically:
- Automatic dump (default): Database Migration Service connects to your source database and performs the initial schema and data dump automatically when the migration job starts. You don't need to prepare anything before you begin the migration.
- Manual dump: You can generate your own dump files and upload them to
a Cloud Storage bucket. This approach can be useful
if you want to reduce the initial load on your primary instance and take
the full dump from a replica, run the dump during a
specific maintenance window, or pass custom export flags. See
Export a MySQL database with
mysqldump.
- Choose and configure your source network connectivity method.
- For public IP allowlist connectivity: At a later point, after Database Migration Service creates the destination instance, you might need to add the Cloud SQL public IP address to your firewall allowlist. Consult your network administrator on how to best schedule such configuration changes.
- Configure your source database instance.
- For continuous migrations, see Configure source database for continuous migrations.
- For one-time migrations, see Configure source database for one-time migrations.
- Create the source connection profile.
Create and run the migration job
To configure and run your migration, perform the following steps:
- Optional: If you want to manage your own certificates for the migration job, prepare the necessary encryption keys.
-
Create and run the migration job.
You can monitor the migration progress, as well as your destination instance health with Database Migration Service observability features. See Migration job metrics.
Finalize the migration
When you decide to switch your application to the new Cloud SQL for MySQL instance, finalize the migration by following these steps:
Continuous migrations
- Stop all write operations on your source database. You can switch them to read-only mode to retain operational functionality.
- Promote the migration job.
- Optional: Verify migration data for completeness.
One-time migrations
When Database Migration Service completes the full dump phase, the destination instance is automatically promoted to a standalone instance. To finalize the migration, follow these steps:
- Optional: Verify migration data for completeness.
- Switch your application to connect to the new Cloud SQL for MySQL instance.
What's next
Learn more about Google Cloud features for Cloud SQL. See Cloud SQL for MySQL features.