Esistono due modi per eseguire l'upgrade della versione principale del database dell'istanza Cloud SQL per MySQL eseguendo la migrazione dei dati.
Opzione 1. Utilizza Database Migration Service (DMS).
DMS supporta la migrazione da un'istanza Cloud SQL MySQL. Puoi anche
utilizzarlo per eseguire l'upgrade della versione di MySQL.
Opzione 2. Sposta i dati da una versione di MySQL a un'altra esportandoli dall'istanza attuale e importandoli in una nuova istanza che esegue la versione successiva di MySQL. Questa procedura
comporta tempi di inattività: devi impostare l'istanza corrente in modalità di sola lettura prima di
avviare l'esportazione.
Considera le funzionalità offerte in ogni versione di MySQL e risolvi
le incompatibilità.
Le nuove versioni principali introducono modifiche incompatibili che potrebbero richiedere di modificare il codice dell'applicazione, lo schema o le impostazioni del database prima di poter eseguire l'upgrade dell'istanza del database. Esamina le note di rilascio della versione principale di destinazione per determinare le incompatibilità da risolvere. Se salti le versioni principali, risolvi le incompatibilità
elencate per ogni versione che salti.
Se esegui l'upgrade da MySQL 5.7 a 8.0, controlla le modifiche alle concessioni degli utenti in MySQL 8.0.
Cloud SQL per MySQL versione 8.0 utilizza un nuovo flag di sistema chiamato
partial_revokes, che è impostato su ON per impostazione predefinita. A differenza di MySQL 5.7, questo
flag rimuove la possibilità di utilizzare caratteri jolly nei comandi GRANT del database.
Per garantire che gli utenti del database abbiano accesso agli schemi di database corretti,
modifica i privilegi degli utenti del database prima di eseguire l'upgrade a MySQL 8.0.
Aggiorna i privilegi dell'utente per utilizzare il nome completo degli schemi di database richiesti anziché utilizzare caratteri jolly.
Esegui una prova del processo di upgrade end-to-end con un'istanza di test
prima di eseguire l'upgrade del database di produzione. Ti consigliamo di testare l'upgrade
utilizzando un clone
anziché il database di produzione per evitare qualsiasi impatto sul rendimento
dell'esportazione sul carico di lavoro di produzione.
Oltre a verificare che l'upgrade venga completato correttamente, esegui
test per assicurarti che l'applicazione si comporti come previsto nel database
aggiornato. Se non hai attivato gli aumenti automatici dello spazio di archiviazione,
prendi nota dello spazio di archiviazione su disco utilizzato dall'istanza di prova aggiornata per
determinare se devi aumentare la capacità di archiviazione per l'istanza di produzione prima dell'upgrade.
Decidi quando eseguire l'upgrade.
Migrazione dei dati
Per eseguire la migrazione dei dati a un'istanza Cloud SQL che esegue una versione più recente del database, segui questi passaggi:
Crea l'istanza con la versione principale del database di destinazione.
Assicurati che l'istanza di destinazione abbia:
Spazio di archiviazione sufficiente per contenere tutti i dati dell'istanza attuale.
Le stesse reti autorizzate dell'istanza corrente.
Scopri di più.
Gli stessi account utente, con gli stessi privilegi e le stesse password MySQL.
Facoltativo. Dopo aver completato la procedura di upgrade, configura la replica
tra le istanze di origine e di destinazione utilizzando un server esterno per aggiornare
la destinazione con tutte le modifiche apportate dall'avvio del dump iniziale. Una volta sincronizzate le due istanze, puoi promuovere l'istanza di destinazione.
Per informazioni sull'utilizzo di un server esterno per implementare la replica continua, consulta Replica da un server esterno.
Aggiorna le applicazioni per connetterti alla nuova istanza.
Quando hai la certezza che la nuova istanza funzioni correttamente,
elimina quella precedente.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Upgrade the database major version by migrating data\n\n\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/sql/docs/postgres/upgrade-major-db-version-migrate \"View this page for the PostgreSQL database engine\") \\| [SQL Server](/sql/docs/sqlserver/upgrade-major-db-version-migrate \"View this page for the SQL Server database engine\")\n\n\u003cbr /\u003e\n\nThis page describes how to migrate your data to an instance running a later\nversion of MySQL. Before proceeding with this method, consider\n[upgrading the database major version in-place](/sql/docs/mysql/upgrade-major-db-version-inplace).\n| **Note:** To upgrade the minor version for MySQL 8.0, see [Upgrade the MySQL minor version for an instance](/sql/docs/mysql/upgrade-minor-db-version).\n\nThere are two ways to upgrade the database major version of your Cloud SQL\nfor MySQL instance by migrating your data.\n\n- **Option 1** . Use the [Database Migration Service (DMS)](/database-migration/docs/mysql/configure-source-database). DMS supports migrating from a Cloud SQL MySQL instance. You can also use it to upgrade your MySQL version.\n- **Option 2** . Move your data from one version of MySQL to another by *exporting* data from the current instance and *importing* 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.\n\nThis page discusses the second option.\n\nPlan a major version upgrade\n----------------------------\n\n1. Choose a target major version.\n\n See the [list of versions that Cloud SQL supports](/sql/docs/mysql/db-versions).\n2. Consider the features offered in each MySQL version and address\n incompatibilities.\n\n New major versions introduce incompatible changes that might require you to\n modify the application code, the schema, or the database settings before\n you can upgrade your database instance. Review the release notes of your\n target major version to determine the incompatibilities that you need to\n address. If you're skipping major versions, address the incompatibilities\n listed for each version that you're skipping.\n - [MySQL 8.4](https://dev.mysql.com/doc/refman/8.4/en/en/mysql-nutshell.html)\n - [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html)\n - [MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html)\n3. If you are upgrading from MySQL 5.7 to 8.0, then check for user grant changes\n in MySQL 8.0.\n\n Cloud SQL for MySQL version 8.0 uses a new system flag called\n `partial_revokes`, which is set to `ON` by default. Unlike MySQL 5.7, this\n flag removes the ability to use wildcard characters in database `GRANT` commands.\n To ensure database users have access to the correct database schemas,\n modify database user privileges before upgrading to MySQL 8.0.\n Update the user's privileges to use the full\n name of the required database schemas instead of using wildcard characters.\n\n For more information on how this flag works in MySQL 8.0,\n see [partial_revokes in MySQL 8.0](/sql/docs/mysql/flags#partial-revokes).\n4. Test the upgrade with a dry run.\n\n Perform a dry run of the end-to-end upgrade process with a test instance\n before you upgrade the production database. You might want to test the upgrade\n using a [clone](/sql/docs/mysql/clone-instance)\n instead of your production database to avoid any performance impact from the\n export on your production workload.\n\n In addition to validating that the upgrade completes successfully, run\n tests to ensure that the application behaves as expected on the upgraded\n database. If you haven't enabled [automatic storage increases](/sql/docs/mysql/instance-settings#automatic-storage-increase-2ndgen),\n take note of the disk storage used by the upgraded dry run instance to\n determine whether you need to increase the storage capacity for the\n production instance before upgrading.\n5. Decide when you want to upgrade.\n\n | **Note:** Upgrades require the instance to become unavailable for a period of time. Be sure to schedule your upgrade when database activity is low.\n\nMigrate your data\n-----------------\n\nTo migrate your data to a Cloud SQL instance running a more recent database\nversion, follow these steps:\n\n1. Create the instance with the target database major version.\n\n Make sure the target instance has:\n - Sufficient storage to hold all of the current instance's data.\n - The same authorized networks as the current instance. [Learn more](/sql/docs/mysql/configure-ip).\n - The same user accounts, with the same MySQL privileges and passwords.\n\n For more information, see [Creating an instance](/sql/docs/mysql/create-instance).\n2. Confirm that you can [connect to the new instance](/sql/docs/mysql/connect-admin-ip) with your local MySQL tools\n and update them if necessary.\n\n3. Put your current Cloud SQL instance into read-only mode by setting the\n `read_only` database flag to `On`.\n\n For information, see [Configure database flags](/sql/docs/mysql/flags).\n4. Export the current instance's data to a SQL dump file, following the\n instructions in\n [Export data for import into Cloud SQL](/sql/docs/mysql/import-export/import-export-sql).\n\n Do *not* export the `mysql` system database.\n5. [Create a Cloud Storage bucket](/storage/docs/creating-buckets)\n if needed, and upload your SQL dump file to the bucket.\n\n6. Import the data to the target instance, following the instructions in\n [Import MySQL databases from Cloud Storage](/sql/docs/mysql/import-export/import-export-sql).\n\n7. Optional. After completing the upgrade process, set up replication\n between the source and target instances by using an external server to update\n the target with all changes that have occurred since the initial dump was\n started. Once the two instances are in sync, you can promote the target\n instance.\n\n For information about using an external server to implement continuous\n replication, see [Replicating from an external server](/sql/docs/mysql/replication/replication-from-external_v1).\n8. Update your applications to connect to the new instance.\n\n9. When you're confident that your new instance is operating successfully,\n delete the old instance.\n\nWhat's next\n-----------\n\n- Learn about [Changes affecting upgrades to MySQL 8.4](https://dev.mysql.com/doc/refman/8.4/en/en/mysql-nutshell.html).\n- Learn about [Changes affecting upgrades to MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html).\n- Learn about [Changes affecting upgrades to MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html).\n- Learn about the [Database Migration Service](/database-migration/docs).\n- Learn about [importing and exporting data](/sql/docs/mysql/import-export).\n- Learn about [options for connecting to an instance](/sql/docs/mysql/external-connection-methods).\n- Learn about [setting MySQL flags](/sql/docs/mysql/flags)."]]