Whenever you define code like routines that have multiple executable statements, you MUST define a custom DELIMITER
. And your code will be sent to the server along with delimiter instruction. And the server compiles the code as a block before it finds the newly defined custom delimiter.
Read what documentation says:
Defining Stored Programs
If you use the mysql client program to define a stored program containing semicolon characters, a problem arises. By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server.
To redefine the mysql delimiter, use the
delimiter
command. .... The delimiter is changed to // to enable the entire definition to be passed to the server as a single statement, and then restored to ; before invoking the procedure. This enables the ; delimiter used in the procedure body to be passed through to the server rather than being interpreted by mysql itself.
I believe your event scheduler code is just executed as is without defining such delimiter
.
Change it as following:
-- set the new delimiter
DELIMITER //
-- include your event scheduler code block here
-- lastly terminate the code block, with new delimiter
-- so that server starts compiling the code
//
-- now reset the delimiter to default
DELIMITER ;
Refer to: CREATE EVENT Syntax