mysql 数据库创建function 的时候提示error 1418

本人菜鸟, 学习mysql数据库的时候 , 创建一个简单的function ,如下:

DELIMITER //
create function add_num( a int  , b int  )  returns int 
begin 
	declare tot int ;
    set tot = a + b ;
    return tot ;
end//
DELIMITER ;

然后就提示错误 :

ERROR code 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)

查了许多度娘,然后就明白了 log_bin_trust_function_creators 的限制效果。

解决方法:

(1)首先查看 log_bin_trust_function_creators 的状态 , 看到是OFF ,要改为ON !

 show variables like 'log_bin_trust_function_creators'  ;

(2) 修改状态

SET @@global.log_bin_trust_function_creators='ON'  ;

(3)重新执行function代码 ,就可以了!!

相关推荐
bug菌¹24 分钟前
滚雪球学Oracle[4.2讲]:PL/SQL基础语法
数据库·oracle
逸巽散人34 分钟前
SQL基础教程
数据库·sql·oracle
月空MoonSky1 小时前
Oracle中TRUNC()函数详解
数据库·sql·oracle
momo小菜pa1 小时前
【MySQL 06】表的增删查改
数据库·mysql
向上的车轮2 小时前
Django学习笔记二:数据库操作详解
数据库·django
编程老船长2 小时前
第26章 Java操作Mongodb实现数据持久化
数据库·后端·mongodb
全栈师3 小时前
SQL Server中关于个性化需求批量删除表的做法
数据库·oracle
Data 3173 小时前
Hive数仓操作(十七)
大数据·数据库·数据仓库·hive·hadoop
BergerLee3 小时前
对不经常变动的数据集合添加Redis缓存
数据库·redis·缓存
程序员大金3 小时前
基于SpringBoot+Vue+MySQL的装修公司管理系统
vue.js·spring boot·mysql