How Do I Export and Import Events and Triggers in Batches?
During the MySQL to MySQL migration, if the migration log indicates that the migration of events and triggers fails after the migration task is complete, you can manually migrate the events and triggers.
This section describes how to export and import events and triggers in batches.
- Export triggers from the source database in batches.
- Run the following statement in the source database to obtain values of TRIGGER_SCHEMA and TRIGGER_NAME:
SELECT TRIGGER_SCHEMA,TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA in ('DB1','DB2','DB3') order by TRIGGER_NAME;
In the preceding statements, DB1, DB2, and DB3 indicate the databases to be migrated to the destination database.
- Run the following statement in the source database to obtain the statement for creating a trigger from the source database from the SQL Original Statement field:
SHOW CREATE TRIGGER TRIGGER_SCHEMA.TRIGGER_NAME \G;
In the preceding statement, replace TRIGGER_SCHEMA and TRIGGER_NAME with the values obtained in 1.a.
- Run the following statement in the source database to obtain values of TRIGGER_SCHEMA and TRIGGER_NAME:
- Export events from the source database in batches.
- Run the following statement in the source database to obtain values of EVENT_SCHEMA and EVENT_NAME:
SELECT EVENT_SCHEMA,EVENT_NAME FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA in ('DB1','DB2','DB3') order by EVENT_NAME;
In the preceding statements, DB1, DB2, and DB3 indicate the databases to be migrated to the destination database.
- Run the following statement in the source database to obtain the statement for creating an event from the source database from the SQL Original Statement field:
SHOW CREATE EVENT EVENT_SCHEMA.EVENT_NAME \G;
In the preceding statement, replace EVENT_SCHEMA and EVENT_NAME with the values obtained in 2.a.
- Run the following statement in the source database to obtain values of EVENT_SCHEMA and EVENT_NAME:
- Import triggers and events.
Execute the statements for creating triggers and events exported from the source database in the destination database.
Real-Time Migration FAQs
- When Can I Stop a Migration Task?
- How Do I Maintain the Original Service User Permission System After Definer Is Forcibly Converted During MySQL Migration?
- What Can I Do If the Invoking Permission Problem Occurs After the MySQL Stored Procedure Is Migrated to the Cloud?
- How Do I Ensure that All Services on the Database Are Stopped?
- What Can I Do When Message "can not get agency token" Is Displayed in the Migration Log
- What Do I Do If the Maximum Index Length Has Been Reached During Migration from Oracle to MySQL?
- Why Is the Collation of Heterogeneous or Oracle Databases Converted to utf8mb4_bin After Those Databases Are Migrated to MySQL?
- What Can I Do If MyISAM Tables Are Not Supported by RDS for MySQL?
- What Are the Precautions for Migrating Data from an Earlier Version MySQL to MySQL 8.0?
- What Can I Do When OOM Occurs During the Migration of MongoDB Databases?
- How Do I Disable the Balancer?
- How Do I Export and Import Events and Triggers in Batches?
- How Can I Migrate Databases or Tables Whose Names Contain Uppercase Letters?
- How Do I Delete Orphaned Documents in MongoDB Sharded Clusters?
- What Can I Do If There Is an Extra Backslash (\) After a MySQL Account Is Migrated?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbotmore