Crear y ejecutar una tarea de migración de MySQL que contenga metadatos con una cláusula DEFINER
Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
Información general
Un trabajo de migración de MySQL no migra datos de usuario. Por lo tanto, las fuentes que contengan metadatos definidos por usuarios con la cláusula DEFINER fallarán cuando se invoquen en la nueva réplica de Cloud SQL, ya que los usuarios aún no existen en ella.
Para identificar qué valores de DEFINER hay en sus metadatos, puede ejecutar las siguientes consultas en su base de datos de origen MySQL. Comprueba los resultados de las entradas de root%localhost o de los usuarios que no existen en la instancia de destino:
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (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."]]