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代码 ,就可以了!!

相关推荐
姓刘的哦1 天前
Qt中的QWebEngineView
数据库·c++·qt
心随_风动1 天前
Ubuntu 文件复制大师:精通cp命令完整指南
数据库·ubuntu·postgresql
不要再敲了1 天前
JDBC从入门到面试:全面掌握Java数据库连接技术
java·数据库·面试
恣艺1 天前
Redis列表(List):实现队列/栈的利器,底层原理与实战
数据库·redis·list
秋难降1 天前
零基础学习SQL(十一):SQL 索引结构|从 B+Tree 到 Hash,面试常问的 “为啥选 B+Tree” 有答案了
数据库·后端·mysql
代码的余温1 天前
Linux内核调优实战指南
linux·服务器·数据库
almighty271 天前
C# DataGridView表头自定义设置全攻略
数据库·c#·winform·datagridview·自定义表头
ljh5746491191 天前
mysql 必须在逗号分隔字符串和JSON字段之间二选一,怎么选
数据库·mysql·json
论迹1 天前
【Redis】-- 持久化
数据库·redis·缓存
getdu1 天前
Redis面试相关
数据库·redis·面试