This document will demonstrate how to migrate a database from Google Cloud Platform (GCP) CloudSQL MySQL Cluster to PlanetScale using our Import tool.
This guide assumes you are using MySQL on GCP. Other database systems available through GCP will not work with the PlanetScale import tool.
You’ll also need to gather the following pieces of information from the GCP Console:
Public IP address
Root username and password
The public IP address can be found in the Overview tab of your CloudSQL cluster under the Connect to this instance section.
A list of your databases can be found in the Databases tab. In this guide, we’ll be using the
root username is the account set up by default for all CloudSQL instances. The password for that account was set during the creation of the instance.
If you don’t know the admin password, you can create a new set of credentials using the information on the Import tool user permissions page to create an account that can be used to import your database.
For PlanetScale to connect to your database, you’ll need to update the Authorized networks for your cluster. The specific IP addresses to permit depend on the region selected for your new database, which is in the New database section of the import tool in the Region field.
You will need to allow traffic for each IP address listed under that region on the Import tool public IP addresses page. To permit traffic from these IP addresses to your database in GCP, select Connections from the navigation on the left. Under Authorized networks, click “Add network”. This will display an inline form for you to add a network. The name of the field is arbitrary, but the Network field should contain the IP address that needs access to your database. Click “Done” to add the new entry. Perform this step for each IP address for the selected region, then click “Save” to apply the settings.
In the PlanetScale dashboard, click “New database”, then “Import database”.
At the time of this writing, the Import database feature is in beta. If this is your first time accessing this feature, you will be prompted to opt into using the feature. Click “Join beta” to proceed.
Complete the form using the information gathered in the previous section. Click "Connect to database” and the import tool will attempt to connect to your GCP CloudSQL instance.
If the connection was successful, you’ll see the following message. Click “Begin database import” to start importing data.
The following view will show you the progress of your data being imported.
Once your database has finished importing, the view will update to show the database that was created in PlanetScale, as well as the option to enable primary mode. This button will make the PlanetScale version of the database the primary replica. Clicking “Enable primary mode” will display a modal where you can confirm that you want to make this change.
After primary mode is enabled, the third card in the flow will update to give you two options. Enable replica mode will revert the change performed in the previous step, whereas Finish import will detach the databases from replication and future changes to either the PlanetScale database or the CloudSQL database will not be replicated to each other. Click “Finish import” to complete the import process. Confirm in the modal that will be displayed.
This concludes the process used to import a database into PlanetScale from GCP CloudSQL.