MySql 创建函数 Error Code : 1418
查看日志信息:show variables like 'log_%';显示'log_bin'、'log_bin_trust_function_creators'等状态
解决方法:
- 关闭binary logging
- 在创建函数 begin 之前加上 DETERMINISTIC READS SQL DATA
SET GLOBAL log_bin_trust_function_creators = 1;
参考 http://dev.mysql.com/doc/refman/5.0/en/stored-programs-logging.html
- To create or alter a stored function, you must have the
SUPER
privilege, in addition to theCREATE ROUTINE
orALTER ROUTINE
privilege that is normally required. (Depending on theDEFINER
value in the function definition,SUPER
might be required regardless of whether binary logging is enabled. See Section 13.1.9, “CREATE PROCEDURE
andCREATE FUNCTION
Syntax”.)
When you create a stored function, you must declare either that it is deterministic or that it does not modify data. Otherwise, it may be unsafe for data recovery or replication.
By default, for a
CREATE FUNCTION
statement to be accepted, at least one ofDETERMINISTIC
,NO SQL
, orREADS SQL DATA
must be specified explicitly. Otherwise an error occurs:ERROR 1418 (HY000): 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)This function is deterministic (and does not modify data), so it is safe:
CREATE FUNCTION f1(i INT)
RETURNS INT
DETERMINISTIC
READS SQL DATA
BEGIN
RETURN i;
END;This function uses
UUID()
, which is not deterministic, so the function also is not deterministic and is not safe:CREATE FUNCTION f2()
RETURNS CHAR(36) CHARACTER SET utf8
BEGIN
RETURN UUID();
END;This function modifies data, so it may not be safe:
CREATE FUNCTION f3(p_id INT)
RETURNS INT
BEGIN
UPDATE t SET modtime = NOW() WHERE id = p_id;
RETURN ROW_COUNT();
END;Assessment of the nature of a function is based on the “honesty” of the creator: MySQL does not check that a function declared
DETERMINISTIC
is free of statements that produce nondeterministic results.To relax the preceding conditions on function creation (that you must have the
SUPER
privilege and that a function must be declared deterministic or to not modify data), set the globallog_bin_trust_function_creators
system variable to 1. By default, this variable has a value of 0, but you can change it like this:mysql>
SET GLOBAL log_bin_trust_function_creators = 1;
You can also set this variable by using the
--log-bin-trust-function-creators=1
option when starting the server.If binary logging is not enabled,
log_bin_trust_function_creators
does not apply.SUPER
is not required for function creation unless, as described previously, theDEFINER
value in the function definition requires it.For information about built-in functions that may be unsafe for replication (and thus cause stored functions that use them to be unsafe as well), see Section 16.4.1, “Replication Features and Issues”.
MySql 创建函数 Error Code : 1418的更多相关文章
- mysql 创建函数 error Code: 1227. Access denied;
mysql> show function status; +------+------------------+----------+------------+----------------- ...
- MySQL 创建函数失败提示1418
MySQL 创建函数失败提示1418 在创建函数时,往往会遇到创建函数失败的情形,除去书写的创建函数的sql语句本身语法错误之外,还会碰到一个错误就是, 1418:This function has ...
- mysql 创建函数ERROR 1418 (HY000): 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_f
mysql 创建函数的时候 报错 ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL D ...
- [转][mysql]创建函数失败(1418错误)mysql双主模式导致的问题
https://blog.csdn.net/qq523786283/article/details/75102170
- MySQL创建函数报“ERROR 1418 ”错误,不能创建函数
MySQL创建函数报ERROR 1418错误,不能创建函数,根据官方提示是说,不能创建函数可能是一个安全设置方面的配置或功能未开启原因,下面我们一起来看. 错误 ERROR 1418 (HY000 ...
- Mysql创建函数出错
目前在项目中,执行创建mysql的函数出错, mysql 创建函数出错信息如下: Error Code: 1227. Access denied; you need (at least one of) ...
- mysql错误:Error Code: 1175. You are using safe update mode and you tried to update a table……
今天遇到一个mysql错误: Error Code: . You are using safe update mode and you tried to update a table withou ...
- mysql 创建函数
<pre name="code" class="html">root 用户创建函数: delimiter $$ CREATE FUNCTION `l ...
- mysql 创建函数This function has none of DETERMINISTIC, NO SQL, or READS
今天在mysql 5.6上创建函数的时候 发现报错: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or R ...
随机推荐
- C# 截屏函数
截屏函数: using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; ...
- python基础知识——包
包是一种通过使用“模块名”来组织python模块的名称空间的方式. 无论是import形式还是from...import形式,凡是在导入语句中(不是在使用时)遇到带点的,就需要意识到——这是包. 包是 ...
- Video标签的使用
现在如果要在页面中使用video标签,需要考虑三种情况,支持Ogg Theora或者VP8(如果这玩意儿没出事的话)的(Opera.Mozilla.Chrome),支持H.264的(Safari.IE ...
- MATLAB画图设置长宽。并高清复制
- Android开发BUG及解决方法
错误描述 问题1: 按照提示打开gradle-wrapper.properties文件 并且将gradle-2.8-all.zip改为gradle-2.10-all.zip,重新导入项目 问题2: 却 ...
- 【leetcode刷题笔记】Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters ...
- Qt5.2.1交叉编译,带tslib插件
一: 源码下载地址: 1.1: 平台: 主机:ubuntu 14.04 开发板: cpu arm-cortex-a8,故而我在配置我的qmake.conf的时候填写的为armV7-a QT版本: qt ...
- 使用Java实现八种基本排序
插入排序.选择排序.冒泡排序.希尔排序.堆排序.快速排序.归并排序.基数排序 import java.util.ArrayList; import java.util.List; /** * 排序算法 ...
- Qt发布程序
一.作用 将Qt软件打包发布成绿色exe,在任意非Qt环境下运行 二.找到我们软件所依赖动态库 使用Qt的windeployqt.exe(在Qt安装目录的bin下面找)--! 1.新建文件夹,在里面放 ...
- linux 虚拟机在线添加新磁盘
在线添加磁盘,扩展LVM卷案例 一.添加硬盘,在线扫描出来 首先到虚拟机那里添加一块硬盘,注意必须是SCSI类型的硬盘. 扫描硬盘,不用重启操作系统的. echo "- - -" ...