Crea ed esegui un job di migrazione MySQL contenente metadati con una clausola DEFINER
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Panoramica
Un job di migrazione MySQL
non esegue la migrazione dei dati utente. Pertanto,
le origini che contengono metadati definiti dagli utenti con la clausola DEFINER non andranno a buon fine se richiamate sulla nuova replica Cloud SQL, perché gli utenti non esistono ancora.
Per identificare i valori DEFINER esistenti nei metadati, puoi eseguire le seguenti query sul database di origine MySQL. Controlla i risultati per le voci per root%localhost o per gli utenti che non esistono nell'istanza di destinazione:
[[["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-05 UTC."],[[["\u003cp\u003eMySQL migration jobs do not migrate user data, leading to potential failures when metadata defined with the \u003ccode\u003eDEFINER\u003c/code\u003e clause is invoked on the new Cloud SQL replica if the users are not present.\u003c/p\u003e\n"],["\u003cp\u003eYou can identify which \u003ccode\u003eDEFINER\u003c/code\u003e values exist in your metadata by running specific queries on your MySQL source database, checking for \u003ccode\u003eroot%localhost\u003c/code\u003e or users absent in the destination instance.\u003c/p\u003e\n"],["\u003cp\u003eTo ensure a successful migration, you must either create the necessary users on the destination Cloud SQL replica before starting the migration job, or update the \u003ccode\u003eDEFINER\u003c/code\u003e clause to \u003ccode\u003eINVOKER\u003c/code\u003e on the source MySQL instance.\u003c/p\u003e\n"],["\u003cp\u003eMetadata created by \u003ccode\u003e'root'@'localhost'\u003c/code\u003e will cause the process to fail, and you will need to change the definer to a different user before starting the migration.\u003c/p\u003e\n"]]],[],null,["# Create and run a MySQL migration job containing metadata with a DEFINER clause\n\n\u003cbr /\u003e\n\nOverview\n--------\n\nA MySQL migration job\n[doesn't migrate user data](/database-migration/docs/mysql/migration-fidelity). Therefore,\nsources which contain metadata defined by users with the `DEFINER` clause will\nfail when invoked on the new Cloud SQL replica, because the users don't yet\nexist there.\n\nTo identify which `DEFINER` values exist in your metadata, you can run the\nfollowing queries on your MySQL source database. Check the results for entries for\neither `root%localhost` or for users that don't exist in the destination instance: \n\n SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA NOT \n IN ('mysql', 'sys');\n SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA NOT \n IN ('mysql', 'sys');\n SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA NOT \n IN ('mysql', 'sys');\n SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA NOT \n IN ('mysql', 'sys');\n\nTo run a migration job from a source which includes such metadata, you can do\none of the following:\n\n- Create the users on the destination Cloud SQL replica instance before starting\n your migration job.\n\n 1. Create a migration job without starting it. That is, choose **Create**\n instead of **Create \\& Start**.\n\n 2. Create the users from your source MySQL instance on your destination\n Cloud SQL instance using the Cloud SQL API or UI.\n\n 3. Start the migration job from the migration job list or the specific job's page.\n\n- Update the `DEFINER` clause to `INVOKER` on your source MySQL instance prior\n to setting up your migration job.\n\n| **Important:** In both cases, if your metadata was created by `'root'@'localhost'`, the process will fail. Change the definer to a different user before starting the migration job."]]