How to delete all events in MySQL

If I want to delete an event, I need to request something like "DROP EVENT IF EXISTS eventname" But I can not find the command to delete all events at one time, I have to delete the event one by one. Is there any SQL to delete all events in one go?

 "DROP EVENT IF EXISTS (SELECT EVENT_NAME FROM information_schema.EVENTS)" 

doesn't work either.

+8
sql database mysql
source share
3 answers

one example:

 DELETE FROM mysql.event WHERE db = 'myschema' AND definer = 'jon@ghidora' AND name = 'e_insert'; 

https://dev.mysql.com/doc/refman/5.1/en/events-privileges.html

if you can delete the event using DROP EVENT IF EXISTS and re-add it with the new scheduled time.

To permanently delete an event yourself, you can use DROP EVENT :

 DROP EVENT [IF EXISTS] event_name 

https://dev.mysql.com/doc/refman/5.1/en/drop-event.html

+12
source share

I think you should use the INFORMATION_SCHEMA.EVENTS table to collect all active events, and then to create and run DROP EVENT statements.

+2
source share

To create a drag and drop event request, you can do something like this:

 select concat('drop event if exists ', event_name, ';') from information_schema.events; 
+1
source share

All Articles