Skip to content

DigitalOcean database migration guide

Learn how to migrate a database from a DigitalOcean MySQL cluster into PlanetScale using the database Import tool.

Introduction

In this article, we’ll walk through migrating a MySQL database from DigitalOcean to PlanetScale using the Import tool.

Note

This guide assumes you are using MySQL on DigitalOcean. Other database systems available through DigitalOcean will not work with the PlanetScale import tool.

We recommend reading through the Database import documentation to learn how our import tool works before proceeding.

Prerequisites

Before you can start migrating your database, you’ll also need to collect the following information from your DigitalOcean cluster:

  • The admin username and password
  • The database host
  • The port
  • Database name

Most of this information is located on the landing page of your cluster.

You can view the list of databases in the "Users & Databases" tab. This article will use the default database created when the cluster was initialized, named defaultdb.

Note

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.

Update trusted sources

In order for PlanetScale to connect to your DigitalOcean database, you must allow network traffic into the database by adding the necessary IP addresses to the trusted sources list in DigitalOcean. The specific IP addresses you will need to allow depend on the region you plan to host your PlanetScale database. Check the Import tool public IP addresses page to determine the IP addresses to allow before continuing. This guide will use the AWS us-east-1 (North Virginia) region so we’ll allow the following addresses:

3.209.149.66
3.215.97.46
34.193.111.15
23.23.187.137
52.6.141.108
52.70.2.89
50.17.188.76
52.2.251.189
52.72.234.74
35.174.68.24
52.5.253.172
54.156.81.4
34.200.24.255
35.174.79.154
44.199.177.24

In the DigitalOcean dashboard, navigate to the “Settings” tab of your database and locate Trusted sources in the list of configuration items. Click “Edit” and the row should change to allow edits to the setting.

When you enter an IP address from the list, a message will appear below the input box asking if you want to add that IP as an address. Click that message to add it to the list. Repeat this step for each IP address that needs to be added, then click “Save” once you are done.

Disable ANSI_QUOTES setting

The default settings for MySQL databases on DigitalOcean is to have ANSI_QUOTES enabled in the global MySQL settings, which is not supported by PlanetScale. To remove this setting, navigate to the "Settings" tab of your cluster and locate the section titled Global SQL mode. Click “Edit” in that section to change the configuration settings.

To remove the ANSI_QUOTES setting, click the “x” next to the tag and click “Save.” The change should apply immediately.

Importing your database

In the PlanetScale dashboard, click “New database”, then “Import database”.

The Import database feature is in beta at the time of this writing. 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 DigitalOcean database.

The “Connect to database” button will update with the connection status.

Note

If your database uses foreign key constraints, we will detect them after successfully connecting to your external database and automatically enable foreign key constraint support for your database.

If the connection is successful and plan upgrades are complete (if the database is over 5 GB), click “Begin database import” to migrate your data to PlanetScale.

You’ll then be moved to a page where you can monitor the import status of the database from DigitalOcean.

Once the initial import has been completed, the first card in the Database import section will update to reflect the status of the import. If it is successful, you’ll have the option to “Enable primary mode,” which will prepare the PlanetScale database to be used as the primary data source. Click “Enable primary mode” & you’ll be presented with a confirmation modal to proceed.

Once Primary mode is enabled, you can complete the migration by clicking “Finish import” and confirming on the modal that will display. This will remove any synchronization occurring between DigitalOcean and PlanetScale.

This concludes the guide to migrating a database from DigitalOcean to PlanetScale.

Need help?

Get help from the PlanetScale support team, or join our GitHub discussion board to see how others are using PlanetScale.

Was this page useful?
Last updated on Help us improve this page