Quickstart

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

  4. Enable the Database Migration Service API.

    Enable the API

  5. Make sure that you have the Database Migration Admin role assigned to your user account.

    Go to the IAM page

Requirements

The 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 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.

  1. Go to the Database Migration Service Connection profiles page in the Google Cloud Console.

    Go to the Database Migration Service Connection Profiles Page

  2. Click CREATE PROFILE.

  3. Open the Source database engine dropdown list and select the classification type of your source database. The options are:

    • A standalone MySQL instance (MySQL)
    • An existing Cloud SQL for MySQL instance (Cloud SQL for MySQL)
    • An AWS RDS instance for MySQL (Amazon RDS for MySQL)

    For this quickstart, select MySQL.

  4. Supply the following information:

    • Enter "My Connection Profile" as the Connection profile name for your source database.

    • 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 dropdown 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), we recommend using SSL/TLS encryption for the connection between the source and destination databases. Otherwise, keep the default value of None.

  5. Click CREATE.

Create a migration job

The 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

  1. Go to the Database Migration Service Migration jobs page in the Google Cloud Console.

    Go to the Database Migration Service Migration Jobs Page

  2. Click CREATE MIGRATION JOB.

  3. Enter "My Migration Job" as the Migration job name.

  4. Keep the auto-generated Migration job ID.

  5. Open the Source database engine dropdown list and select the classification type of your source database. Database Migration Service selects the Destination database engine automatically.

  6. Select the Region where the destination instance is to be created.

  7. 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.

  8. 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 a source database.

  9. Click SAVE & CONTINUE.

Specify information about the source connection profile

  1. Open the Select source connection profile dropdown list and select the connection profile that you created.

  2. Click SAVE & CONTINUE.

Define settings for the destination Cloud SQL instance

  1. 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.

  2. Provide an alphanumeric Root 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.

  3. Choose the Database version for the destination instance from the list of supported Cloud SQL versions for the specified database engine.

  4. Select the desired Google Cloud Zone for the new Cloud SQL instance (or leave as "Any").

  5. 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.

  6. Select the Machine type for the Cloud SQL instance. The disk size must be equal to or greater than the source database size.

  7. Define the Storage type and Storage capacity for the Cloud SQL instance.

  8. Click CREATE & CONTINUE to create the new instance.

  9. Click CREATE DESTINATION & CONTINUE in the subsequent dialog box. Creating the instance may take several minutes to complete.

Set up connectivity

  1. 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 dropdown list to select IP allowlist as the networking method.
  2. 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.
    1. 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.
  3. Click CONFIGURE & CONTINUE to complete the connection profile configuration.

Test and create the migration job

  1. Review the settings you chose for the migration job.

  2. 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.

  3. 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.

  4. Click CREATE & START JOB to create the migration job and start it immediately.

  5. Click START in the subsequent dialog box.

  6. 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.

  1. Go to the SQL Instances page in the Google Cloud Console.
  2. Click the read replica entry of your migration job.
  3. Scroll down until the Connect to this instance pane appears, and then click Connect using Cloud Shell.
  4. At the Google Cloud Shell prompt, press Enter.
  5. Optional: If an Authorize Cloud Shell dialog box appears, then click Authorize.
  6. At the Enter password prompt, enter the password that you either provided or that Database Migration Service generated for you in Define settings for the destination Cloud SQL instance.
  1. At the mysql prompt, enter show databases; to list the databases and verify that you see your source database instance.
  2. At the mysql prompt, enter use source_database_instance_name; because you want to see the tables associated with this database instance.
  3. At the mysql prompt, enter show tables; to see the tables of this instance.
  4. At the mysql prompt, enter select * from table_name; to see the information that's replicated from a table in your source database instance.
  5. Verify that you see the correct information in the table.

This confirms that the 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.

  1. Return to the Migration jobs page.

  2. Wait for the replication delay to trend toward zero.

  3. Stop all writes to the source database.

  4. Wait until the replication delay is at zero.

  5. Click the migration job that you want to promote. This job should have a status of "Running".

  6. Click PROMOTE to promote the migration job.

  7. Click PROMOTE again in the subsequent dialog box.

  8. 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 in this quickstart, follow these steps.

  1. Use the Google Cloud Console to delete your migration job, Cloud SQL instance, and project if you don't need them.

What's next