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

相关推荐
q***47184 分钟前
使用Canal将MySQL数据同步到ES(Linux)
linux·mysql·elasticsearch
避避风港28 分钟前
MySQL 从入门到实战
数据库·mysql
s***45330 分钟前
MSSQL2022的一个错误:未在本地计算机上注册“Microsoft.ACE.OLEDB.16.0”提供程序
数据库·microsoft
能鈺CMS1 小时前
能鈺CMS · 虚拟发货源码
java·大数据·数据库
泡沫·1 小时前
4.iSCSI 服务器
运维·服务器·数据库
胡八一2 小时前
解决PHP未检测到您服务器环境的sqlite3数据库扩展报错
服务器·数据库·php
Wang's Blog2 小时前
MongoDB小课堂: 游标操作与文档投影技术深度解析
数据库·mongodb
q***42052 小时前
使用Django Rest Framework构建API
数据库·django·sqlite
共享家95273 小时前
QT-界面优化(下)
开发语言·数据库·qt
maray3 小时前
Chroma 的设计哲学
数据库·人工智能