查看日志信息:show variables like 'log_%';显示'log_bin'、'log_bin_trust_function_creators'等状态

解决方法:

  1. 关闭binary logging
  2. 在创建函数 begin 之前加上 DETERMINISTIC READS SQL DATA
  3. SET GLOBAL log_bin_trust_function_creators = 1;

参考  http://dev.mysql.com/doc/refman/5.0/en/stored-programs-logging.html

  • 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 of DETERMINISTICNO SQL, or READS 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 global log_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=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, the DEFINER 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的更多相关文章

  1. mysql 创建函数 error Code: 1227. Access denied;

    mysql> show function status; +------+------------------+----------+------------+----------------- ...

  2. MySQL 创建函数失败提示1418

    MySQL 创建函数失败提示1418 在创建函数时,往往会遇到创建函数失败的情形,除去书写的创建函数的sql语句本身语法错误之外,还会碰到一个错误就是, 1418:This function has ...

  3. 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 ...

  4. [转][mysql]创建函数失败(1418错误)mysql双主模式导致的问题

    https://blog.csdn.net/qq523786283/article/details/75102170

  5. MySQL创建函数报“ERROR 1418 ”错误,不能创建函数

    MySQL创建函数报ERROR 1418错误,不能创建函数,根据官方提示是说,不能创建函数可能是一个安全设置方面的配置或功能未开启原因,下面我们一起来看.   错误 ERROR 1418 (HY000 ...

  6. Mysql创建函数出错

    目前在项目中,执行创建mysql的函数出错, mysql 创建函数出错信息如下: Error Code: 1227. Access denied; you need (at least one of) ...

  7. 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 ...

  8. mysql 创建函数

    <pre name="code" class="html">root 用户创建函数: delimiter $$ CREATE FUNCTION `l ...

  9. 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 ...

随机推荐

  1. selenium网页没加载完成就停止加载并自动刷新

    判断一个网页10秒没加载完成就停止加载并自动刷新 driver=webdriver.Chome() driver.set_page_load_timeout(10) while True: try: ...

  2. Java系列之EJB 理解

    EJB = Enterprise Java Bean,它和JavaBean有本质的区别,最好不要将他们混淆起来,就像不要将Java和 Javascript混淆起来一样.EJB有3中类型:Session ...

  3. 【Tech】SQL Server2008使用笔记

    1.64位win7系统报错“未在本地计算机上注册 Microsoft.ACE.OLEDB.12.0 ”. 解决方法:从这个网址下载和安装一个驱动http://www.microsoft.com/zh- ...

  4. goseq

    goseq是一个R包,用于寻找GO terms,即基因富集分析. GO terms是标准化描述基因或基因产物的词汇,包括三方面,cellular component,molecular funcito ...

  5. classpath是什么

    作用: 告诉Java执行环境,在哪些目录下可以找到您所要执行的Java程序所需要的类或者包(也就是.class文件) JDK 5.0默认就会到JDK的lib目录下寻找Java程序. 如何配置? 有许多 ...

  6. box-flex兼容写法

    box-flex布局在这几年发生了多次变化,可分为2009版.2011版以及2013版, 区分: display:box(inline-box), box-{*}的格式为2009版 display:b ...

  7. php的正则表达式

    这篇文章介绍的内容是关于php的正则表达式 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下. 正则表达式是一种描述字符串结果的语法规则,是一个特定的格式化模式,可以匹配.替换.截取匹配 ...

  8. Python 列表List的定义及操作

    # 列表概念:有序的可变的元素集合 # 定义 # 直接定义 nums = [1,2,3,4,5] # 通过range函数构造,python2 和python3 版本之间的差异: # python3 用 ...

  9. VMware ESXI 6.5安装教程

    设置从IPMI Virtual Disk 3000启动,出现如下界面: 默认选择第一项,回车安装 安装程序正在检测服务器硬件信息,如果不满足系统安装条件会跳出错误提示. 检测完成之后会出现下面界面 回 ...

  10. makefile下$(wildcard $^),$^,$@,$?,$<,$(@D),$(@F) 含义

    makefile下$(wildcard $^),$^,$@,$?,$<,$(@D),$(@F)代表的不同含义 $(filter-out $(PHONY) $(wildcard $^),$^) 常 ...