Upgrade the database major version by migrating data Stay organized with collections Save and categorize content based on your preferences.
This page describes how to migrate your data to an instance running a laterversion of MySQL. Before proceeding with this method, considerupgrading the database major version in-place.
Note: To upgrade the minor version for MySQL 8.0, seeUpgrade the MySQL minor version for an instance.There are two ways to upgrade the database major version of your Cloud SQLfor MySQL instance by migrating your data.
- Option 1. Use theDatabase Migration Service (DMS). DMS supports migrating from a Cloud SQL MySQL instance. You can also use it to upgrade your MySQL version.
- Option 2. Move your data from one version of MySQL to another byexporting data from the current instance andimporting that data into a new instance running the later version of MySQL. This process involves downtime; you put the current instance into read-only mode before starting the export.
This page discusses the second option.
Plan a major version upgrade
Choose a target major version.
Consider the features offered in each MySQL version and addressincompatibilities.
New major versions introduce incompatible changes that might require you tomodify the application code, the schema, or the database settings beforeyou can upgrade your database instance. Review the release notes of yourtarget major version to determine the incompatibilities that you need toaddress. If you're skipping major versions, address the incompatibilitieslisted for each version that you're skipping.
If you are upgrading from MySQL 5.7 to 8.0, then check for user grant changesin MySQL 8.0.
Cloud SQL for MySQL version 8.0 uses a new system flag called
partial_revokes, which is set toONby default. Unlike MySQL 5.7, thisflag removes the ability to use wildcard characters in databaseGRANTcommands.To ensure database users have access to the correct database schemas,modify database user privileges before upgrading to MySQL 8.0.Update the user's privileges to use the fullname of the required database schemas instead of using wildcard characters.For more information on how this flag works in MySQL 8.0,seepartial_revokes in MySQL 8.0.
Test the upgrade with a dry run.
Perform a dry run of the end-to-end upgrade process with a test instancebefore you upgrade the production database. You might want to test the upgradeusing acloneinstead of your production database to avoid any performance impact from theexport on your production workload.
In addition to validating that the upgrade completes successfully, runtests to ensure that the application behaves as expected on the upgradeddatabase. If you haven't enabledautomatic storage increases,take note of the disk storage used by the upgraded dry run instance todetermine whether you need to increase the storage capacity for theproduction instance before upgrading.
Decide when you want to upgrade.
Note: Upgrades require the instance to become unavailable for a period oftime. Be sure to schedule your upgrade when database activity is low.
Migrate your data
To migrate your data to a Cloud SQL instance running a more recent databaseversion, follow these steps:
Create the instance with the target database major version.
Make sure the target instance has:
- Sufficient storage to hold all of the current instance's data.
- The same authorized networks as the current instance.Learn more.
- The same user accounts, with the same MySQL privileges and passwords.
For more information, seeCreating an instance.
Confirm that you canconnect to the new instance with your local MySQL toolsand update them if necessary.
Put your current Cloud SQL instance into read-only mode by setting the
read_onlydatabase flag toOn.For information, seeConfigure database flags.
Export the current instance's data to a SQL dump file, following theinstructions inExport data for import into Cloud SQL.
Donot export the
mysqlsystem database.Create a Cloud Storage bucketif needed, and upload your SQL dump file to the bucket.
Import the data to the target instance, following the instructions inImport MySQL databases from Cloud Storage.
Optional. After completing the upgrade process, set up replicationbetween the source and target instances by using an external server to updatethe target with all changes that have occurred since the initial dump wasstarted. Once the two instances are in sync, you can promote the targetinstance.
For information about using an external server to implement continuousreplication, seeReplicating from an external server.
Update your applications to connect to the new instance.
When you're confident that your new instance is operating successfully,delete the old instance.
What's next
- Learn aboutChanges affecting upgrades to MySQL 8.4.
- Learn aboutChanges affecting upgrades to MySQL 8.0.
- Learn aboutChanges affecting upgrades to MySQL 5.7.
- Learn about theDatabase Migration Service.
- Learn aboutimporting and exporting data.
- Learn aboutoptions for connecting to an instance.
- Learn aboutsetting MySQL flags.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.