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 小时前
MySQL知识回顾总结----数据库基础
数据库·mysql
lubiii_1 小时前
SQL手工测试(MySQL数据库)
数据库·mysql·web安全·网络安全
凌辰揽月1 小时前
Web后端基础(基础知识)
java·开发语言·前端·数据库·学习·算法
想你依然心痛1 小时前
数据库入门:从原理到应用
数据库
20242817李臻3 小时前
20242817李臻-安全文件传输系统-项目验收
数据库·安全
行思理3 小时前
MongoDB慢查询临时开启方法讲解
数据库·mongodb
bbsh20993 小时前
WebFuture 升级提示“不能同时包含聚集KEY和大字段””的处理办法
数据库·sql·mysql·webfuture
霖檬ing3 小时前
Python——MySQL远程控制
开发语言·python·mysql
Zfox_7 小时前
Redis:Hash数据类型
服务器·数据库·redis·缓存·微服务·哈希算法
陈丹阳(滁州学院)9 小时前
若依添加添加监听容器配置(删除键,键过期)
数据库·oracle