When using a SQL file placed inside /docker-entrypoint-initdb.d/ defining functions fails with the following error:
ERROR 1064 (42000) at line 6: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3
This is the content of the SQL file:
CREATE DATABASE alpha;
USE alpha;
SET GLOBAL log_bin_trust_function_creators = 1;
create function addit(a int, b int) returns int
begin
return a+b;
end
The above code works perfectly well when I connect to the instance after creation and run it.
Is it not allowed to define functions in db init scripts? How do I get around this?