mysql定义变量报错declare语句

declare i int default 0;
每次都会在这个语句报错
mysql> create FUNCTION procedure(start int, max_num int)
-> begin
-> declare i int default 0;
-> repeat
-> set i = i+1;
-> insert into emp values((start+i),floor(rand()*10));
-> until i = max_num end repeat;
-> end //
ERROR 1064 (42000): 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 'procedure(start int, max_num int)
begin
declare i int default 0;
repeat
set i = ' at line 1

1、你是用云服务器吗?如果是,看第二条
2、你是用了读写分离吗?如果是,单独连接写库即可。
3、如果不是云服务器,也没有用读写分离,那就你的数据库版本不支持