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

相关推荐
星霜笔记3 小时前
Docker 部署 MariaDB+phpMyAdmin+Nextcloud 完整教程
运维·数据库·docker·容器·mariadb
poemyang7 小时前
十年大厂员工终明白:MySQL性能优化的尽头,是对B+树的极致理解
mysql·pagecache·顺序i/o·局部性原理·b tree·b+ tree
wyiyiyi9 小时前
【Web后端】Django、flask及其场景——以构建系统原型为例
前端·数据库·后端·python·django·flask
天宇_任9 小时前
Mysql数据库迁移到GaussDB注意事项
数据库·mysql·gaussdb
xiep143833351012 小时前
Ubuntu 安装带证书的 etcd 集群
数据库·etcd
Java小白程序员13 小时前
Spring Framework:Java 开发的基石与 Spring 生态的起点
java·数据库·spring
老虎062713 小时前
数据库基础—SQL语句总结及在开发时
数据库·sql·oracle
爱掘金的土拨鼠15 小时前
国产化dm数据库锁表解锁
数据库
花花无缺15 小时前
MySQL 的存储引擎-InnoDB 和 MyISAM的对比
mysql
苏琢玉15 小时前
如何让同事自己查数据?写一个零依赖 PHP SQL 查询工具就够了
mysql·php