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

相关推荐
墨白曦煜4 分钟前
深入剖析 Redis 客户端:Sentinel 模式下的“寻址”与“感知”艺术
数据库·redis·sentinel
水上冰石7 分钟前
harbor使用https之证书生成
服务器·数据库·https
韩zj18 分钟前
服务器定时备份数据库脚本
服务器·数据库·adb
Cat God 00721 分钟前
基于 CentOS 7.6 的 MySQL 8.0 主从复制
linux·服务器·mysql·centos
笨蛋少年派28 分钟前
Maxwell数据变更捕获工具简介
数据库·mysql
谷新龙00136 分钟前
pg_clickhouse插件,在postgresql中借助clickhouse借用OLAP能力
数据库·clickhouse·postgresql
Hello.Reader37 分钟前
Flink SQL 的 SET 语句会话参数配置与快速自检(SQL CLI 实战)
数据库·sql·flink
老华带你飞1 小时前
工会管理|基于springboot 工会管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·spring
自在极意功。1 小时前
MyBatis配置文件详解:environments、transactionManager与dataSource全面解析
java·数据库·tomcat·mybatis
紫金桥软件1 小时前
紫金桥软件 | 赋能工业数字化转型
数据库·国产化