I need to re-create a single trigger in another mysql database - is there an easy way to export a single trigger?
To export a trigger, simply go to the “All Triggers” list and hover over a trigger, then click the “Export” button. A file with the same name will be automatically downloaded to your PC.
First, specify the name of the trigger that you want to create after the CREATE TRIGGER keywords. Second, use AFTER INSERT clause to specify the time to invoke the trigger. Third, specify the name of the table on which you want to create the trigger after the ON keyword.
Mysqldump will attempt to dump all the triggers in your database by default. To be able to dump a table's triggers , you must have the TRIGGER privilege for the table.
What you want is a dump of single trigger of your db.
You can take inspiration from this article and from documentation.
For example, this command export only the stored procedures and triggers:
mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql
However, I do not think you can dump a single trigger. Since it's only one, maybe it's easier to recreate another dabatase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With