This quickstart shows you how to use Database Migration Service to migrate data to Cloud SQL for MySQL. The resources created in this quickstart typically cost less than one dollar (USD), assuming you complete the steps, including the clean up, in a timely manner.
Before you begin
Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Database Migration Service offers a variety of source database options and connectivity methods. Different sources work better with some connectivity methods than with others. In this quickstart, we assume that you're using a standalone MySQL database in an environment where you can configure your network to add an inbound firewall rule. The source database can be on-premises or in a cloud provider. Because we can't know the specifics of your environment, we can't provide detailed steps when it comes to your networking configuration.
In this quickstart, you'll select MySQL for the Source database engine and IP allowlist as the networking method.
Create a source connection profile
By creating a connection profile, you're creating a record that contains information about the source database. Database Migration Service uses the information in the connection profile to migrate data from your source database to the destination Cloud SQL database instance.
Go to the Database Migration Service Connection profiles page in the Google Cloud console.
On the Create a connection profile page, from the Profile role list, select Source.
From the Database engine list, select one of the following classification types of your source database:
A standalone MySQL instance (MySQL)
An existing Cloud SQL for MySQL instance (Cloud SQL for MySQL)
An Amazon RDS instance for MySQL (Amazon RDS for MySQL)
For this quickstart, select MySQL.
Supply the following information:
In the Connection profile name field, enter a name for the connection profile for your source database, such as My Connection Profile.
Keep the auto-generated Connection profile ID.
Enter Connectivity information:
If you're replicating from a self-hosted database, then enter the Hostname or IP address (domain or IP) and Port to access the host. (The default MySQL port is 3306.)
If you're replicating from a Cloud SQL database, then select the Cloud SQL instance from the drop-down list.
Enter a Username and Password to authenticate to your source instance.
(Optional) If you plan to transfer sensitive information over a public network (by using IP allowlists), then we recommend using SSL/TLS encryption for the connection between the source and destination databases. Otherwise, keep the default value of None.
In the Connection profile region section of the page, select the region where you want to save the connection profile.
Click CREATE.
Create a migration job
Database Migration Service uses migration jobs to migrate data from your source database instance to the destination Cloud SQL database instance.
Creating a migration job includes:
Defining settings for the job
Selecting the connection profile that you created for your source database (source connection profile)
Defining settings for the destination Cloud SQL database instance
Setting up connectivity between the source and destination database instances
Testing the migration job to ensure that the connection information you provided for the job is valid
Define settings for the migration job
Go to the Database Migration Service Migration jobs page in the Google Cloud console.
In the Migration job name field, enter a name for the migration job, such as My Migration Job.
Keep the auto-generated Migration job ID.
Open the Source database engine drop-down list and select the classification type of your source database. Database Migration Service selects the Destination database engine automatically.
Select the Destination region where the destination instance is to be created.
Set the Migration job type to "Continuous" because you want ongoing changes in your source database to be migrated to the destination Cloud SQL database instance.
Review the required prerequisites that are generated automatically to reflect how the environment must be prepared for a migration job. These prerequisites can include how to configure the source database and how to connect it to the destination Cloud SQL database instance. It's best to complete these prerequisites at this step, but you can complete them at any time before you test the migration job or start it. For more information about these prerequisites, see Configure your source.
Click SAVE & CONTINUE.
Specify information about the source connection profile
Open the Select source connection profile drop-down list and select the connection profile that you created.
Click SAVE & CONTINUE.
Define settings for the destination Cloud SQL instance
Provide a Destination Instance ID for the Cloud SQL instance. By default, the migration job ID is pre-populated in this field. You can keep this name or enter another name.
Provide an alphanumeric password for the destination Cloud SQL instance. This will be the password for the root administrator account in the instance.
You can either enter the password manually or click GENERATE to have Database Migration Service create one for you automatically.
Choose the Database version for the destination instance from the list of supported Cloud SQL versions for the specified database engine.
Select the desired Google Cloud Zone for the new Cloud SQL instance (or leave as "Any").
Select the Public IP check box because, for this quickstart, you're using IP allowlist as the networking method. This method works by configuring the source database server to accept connections from the outgoing IP address of the Cloud SQL instance.
Select the Machine type for the Cloud SQL instance. The disk size must be equal to or greater than the source database size.
Define the Storage type and Storage capacity for the Cloud SQL instance.
Click CREATE & CONTINUE to create the new instance.
Click CREATE DESTINATION & CONTINUE in the subsequent dialog box. Creating the instance may take several minutes to complete.
Set up connectivity
Choose the networking method that you'd like to use to establish connectivity between the source and destination databases. For this quickstart, use the Connectivity method list to select IP allowlist as the networking method.
If the source IP address isn't pre-populated in this field, then copy the Cloud SQL instance's outgoing IP address from the console, and use it to configure the network firewall for the source database server to accept connections from this IP address.
In your firewall rules, create an Inbound (or Ingress) rule to allow connections on port 3306 from the destination Cloud SQL instance's connectivity IP address.
Click CONFIGURE & CONTINUE to complete the connection profile configuration.
Test and create the migration job
Review the settings you chose for the migration job.
Click TEST JOB to verify that the source has been configured correctly, that the source and destination instances are able to communicate with each other, and that the migration job is valid.
Verify that you see the "Tests passed successfully!" status.
If the test fails, then you can address the problem in the appropriate part of the flow, and return to re-test.
Click CREATE & START JOB to create the migration job and start it immediately.
Click START in the subsequent dialog box.
In the Migration jobs page, verify that your migration job has a status of "Starting". After a few minutes, confirm that the status changes to "Running".
Verify the migration job
In this section, you confirm that Database Migration Service used the migration job to migrate data from your source database instance to the destination Cloud SQL database instance.
Go to the SQL Instances page in the Google Cloud console.
Click the read replica entry of your migration job.
Click the Activate Cloud Shell icon that appears in the upper-right region of the page.
At the Google Cloud Shell prompt, press Enter.
Optional: If an Authorize Cloud Shell dialog box appears, then click Authorize.
Connect to the destination Cloud SQL database instance.
At the mysql prompt, enter show databases; to list the databases and verify that you see your source database instance.
At the mysql prompt, enter use source_database_instance_name; because you want to see the tables associated with this database instance.
At the mysql prompt, enter show tables; to see the tables of this instance.
At the mysql prompt, enter select * from table_name; to see the information that's replicated from a table in your source database instance.
Verify that you see the correct information in the table.
This confirms that Database Migration Service migrated the data.
Promote the migration job
You're ready to promote the migration job. As a result, the destination Cloud SQL database instance replaces the source database instance as the primary database.
Return to the Migration jobs page.
Click the migration job that you want to promote. The Migration job details page appears.
Wait for the replication delay to trend toward zero.
Stop all writes to the source database.
Wait until the replication delay is at zero.
Click the migration job that you want to promote. This job should have a status of "Running".
Click PROMOTE to promote the migration job.
Click PROMOTE again in the subsequent dialog box.
Verify that the migration job has a status of "Promote in progress". After a few minutes, confirm that the status changes to "Completed".
Your new Cloud SQL database instance is ready to use.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Use the Google Cloud console to delete your migration job, connection profile, Cloud SQL instance, and project if you don't need them.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-17 UTC."],[[["This quickstart guide demonstrates how to migrate data to Cloud SQL for MySQL using the Database Migration Service, which can typically cost less than one dollar to complete."],["The process involves enabling the Database Migration Service API and creating a source connection profile, which stores information about your source database (like MySQL, Cloud SQL for MySQL, or Amazon RDS for MySQL), and setting up connectivity via IP allowlists for this guide."],["A migration job is created to facilitate data migration from the source to the destination Cloud SQL database instance, including defining settings, selecting a connection profile, and configuring connectivity."],["After defining the destination Cloud SQL instance, including its ID, password, version, zone, and machine type, the user must configure a networking method to establish connectivity, such as the IP allowlist method detailed in this quickstart."],["The guide concludes with instructions on testing the migration job, promoting it to make the Cloud SQL database instance the primary, verifying the migrated data, and finally cleaning up resources to avoid ongoing charges."]]],[]]