mysql 1418错误解决

记录mysql创建function是遇到的问题:参考:MySQL 创建函数失败提示1418 - 落日长烟 - 博客园

创建mysql函数:

drop function if EXISTS getUnitChildList;
create function getUnitChildList(rootId BIGINT)
RETURNS varchar(2000)
begin
	declare sChildList varchar(2000);
	declare sChildTemp varchar(1000);
	set sChildTemp = cast(rootId as char); -- 将rootId强转为字符
	while sChildTemp is not null do
		if(sChildList is not null ) then
			set sChildList = concat(sChildList,',',sChildTemp);
		else 
			set sChildList = concat(sChildTemp);
		end if;
		select group_concat(menu_id) into sChildTemp from sys_menu_info where find_in_set(parent_id,sChildTemp)>0;
	end while;
	return sChildList;
end;

执行报错:

> 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

原因:创建函数功能关闭;

查看方式:执行以下语句

show variables like '%func%';

结果为:

说明该功能关闭;需要开启此功能:

set global log_bin_trust_function_creators=1;

再查看是否看启:

结果为以下,则说明成功

 再次执行函数sql成功。

 

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值