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
SUPERprivilege, in addition to theCREATE ROUTINEorALTER ROUTINEprivilege that is normally required. (Depending on theDEFINERvalue in the function definition,SUPERmight be required regardless of whether binary logging is enabled. See Section 13.1.9, “CREATE PROCEDUREandCREATE FUNCTIONSyntax”.)
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 FUNCTIONstatement to be accepted, at least one ofDETERMINISTIC,NO SQL, orREADS SQL DATAmust 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
DETERMINISTICis free of statements that produce nondeterministic results.To relax the preceding conditions on function creation (that you must have the
SUPERprivilege and that a function must be declared deterministic or to not modify data), set the globallog_bin_trust_function_creatorssystem 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=1option when starting the server.If binary logging is not enabled,
log_bin_trust_function_creatorsdoes not apply.SUPERis not required for function creation unless, as described previously, theDEFINERvalue 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 ...
随机推荐
- maven 项目打包时无法解析读取properties文件
在做项目时遇见一个问题,无法解析properties文件的 内容 异常为 Could not resolve placeholder ......... 在此之前均有做相关的 配置 但是从未出现过如上 ...
- CSS清除浮动使父级元素展开的三个方法
点评:一个没有设置高度的容器div内如果存在浮动元素(即使用了属性float:left或者float:right),那么该父级元素会无法展开,下面举个例子为大家详细介绍下,希望对大家有所帮助 一个没有 ...
- C# RSACryptoServiceProvider加密解密签名验签和DESCryptoServic
C#在using System.Security.Cryptography下有 DESCryptoServiceProvider RSACryptoServiceProvider DESCryptoS ...
- 六、golang中的结构体和方法、接口
结构体: 1.用来自定义复杂数据结构 2.struct里面可以包含多个字段(属性) 3.struct类型可以定义方法,注意和函数的区分 4.strucr类型是值类型 5.struct类型可以嵌套 6. ...
- Whitewidow:SQL 漏洞自动扫描工具
Whitewidow 是一个开源的 SQL 漏洞自动扫描器,可用通过文件列表运行,或者从 Google 爬取并发现有潜在漏洞的网站. 这个工具支持自动格式化文件.随机用户代理.IP 地址.服务器信息. ...
- Windows 端口和所提供的服务
一 .端口大全 端口:0 服务:Reserved 说明:通常用于分析操作系统.这一方法能够工作是因为在一些系统中“0”是无效端口,当你试图使用通常的闭合端口连接它时将产生不同的结果.一种典型的扫描,使 ...
- javaMail发送邮件实例
背景:最近项目里有个实时发送邮件的功能,今天闲下来整理 一下,记录下来方便以后直接使用. 代码: package com.dzf.utils; import java.io.File; import ...
- 用java.lang.Math.random()语句,随机输出{size:自定义参数}个数不重复并且按顺序从小到大排列(冒泡排序)
package com.test; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lan ...
- JAVA 写中文字符串到指定文件 中文乱码 问题解决
之前试过下面代码里面的注释掉的 方法,都不行,后来想到了不如指定编码格式试试,果真可以了. String as= “中文字符”; //byte[] b = as.getBytes(); try{ Fi ...
- Kafka详解三:开发Kafka应用
问题导读 1.Kafka系统由什么组成?2.Kafka中和producer相关的API是什么? 一.整体看一下Kafka 我们知道,Kafka系统有三大组件:Producer.Consu ...