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

相关推荐
Old Uncle Tom42 分钟前
Harness Engineering 综述
java·开发语言·数据库
疯狂打码的少年1 小时前
Cache的三种映射方式(直接/全相联/组相联)
linux·服务器·数据库·笔记
我是一颗柠檬1 小时前
【MySQL全面教学】MySQL备份与恢复Day14(2026年)
数据库·后端·mysql
渣渣盟1 小时前
MySQL DDL操作全解析:从入门到精通,包含索引视图分区表等全操作解析
大数据·数据库·mysql
小小工匠2 小时前
Redis - 基本架构:一个键值数据库到底由什么组成
数据库·redis·架构
mN9B2uk172 小时前
为mysql数据库建立索引
数据库·mysql·oracle
SilentSamsara2 小时前
SQLAlchemy 2.x:异步 ORM 与数据库迁移 Alembic 完整指南
开发语言·数据库·python·sql·青少年编程·oracle·fastapi
流星白龙2 小时前
【MySQL高阶】7.MySQL日志
数据库·mysql·adb
Irene19912 小时前
SQL示例:正确理解题意(隐藏分组键)严格SQL模式下,ORDER BY中的列必须出现在GROUP BY中或作为聚合函数
mysql
流星白龙2 小时前
【MySQL高阶】0.MySQL的安装
数据库·mysql·adb