Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all events in MySQL

If I want to delete some event I need to query something like "DROP EVENT IF EXISTS eventname" But I can't find the command of deleting all the events at one time,must delete event one by one. Is there some SQL of deleting all events at one time?

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

is not working either.

like image 341
Yellove Avatar asked Apr 18 '14 08:04

Yellove


1 Answers

sample one:

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 with 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

like image 160
jmail Avatar answered Oct 06 '22 01:10

jmail