You are missing custom delimiter
instruction.
As you missed it, engine tried to compile the statements when it found the first default statement terminator, the semicolon ;
. And hence the exception.
Place your entire routine in between:
-- define the delimiter
delimiter //
--- place here your stored procedure
-- and lastly following line
//
-- reset the delimiter
delimiter ;