I experienced this error while trying to alter one of my stored procedures remotely on a master server. After some research, I ended up getting information from “Binary Logging of Stored Programs“.

From MySQL Reference in verbatim:
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 DETERMINISTIC, NO 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)

Further reading helped me arrive to the conclusion to the cause of this error:

Cause:
The error arises if the binary logging option, which is required for the replication, is turned on for the MySQL server.

We can choose solutions listed below depending to our system requirements, for me, I opted on using the later.

  1. When creating or altering 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.
  2. 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_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.

 

MySQL Open Source Software Development

POSTED ON SUNDAY, NOVEMBER 11TH, 2012 AT 11:54 PM PRINT THIS ARTICLE EMAIL THIS ARTICLE

 
 
 

ob·liv·i·on

noun \ə-ˈbli-vēən\
Reference : Merriam-Webster
  1. the fact or condition of forgetting or having forgotten; especially : the condition of being oblivious
  2. the condition or state of being forgotten or unknown
 

tH3 oBlivIOus

Aldwin Llacuna Galapon
IT Consultant / Software and Web Developer

 

Do not take life too seriously. You might not get out of it alive!

 
  • FACEBOOK
  • TWITTER
 
 
 

mysql 报错之创建自定义函数的更多相关文章

  1. mysql创建自定义函数与存储过程

    mysql创建自定义函数与存储过程 一 创建自定义函数 在使用mysql的过程中,mysql自带的函数可能不能完成我们的业务需求,这时就需要自定义函数,例如笔者在开发过程中遇到下面这个问题 mysql ...

  2. MySQL 创建自定义函数(2)

    说明:下面创建一个函数,调用自定义函数返回一个返回一个随机数. (1) 创建自定义函数

  3. 开启bin-log日志mysql报错:This function has none of DETERMINISTIC, NO SQL解决办法

    开启bin-log日志mysql报错:This function has none of DETERMINISTIC, NO SQL解决办法: 创建存储过程时 出错信息: ERROR 1418 (HY ...

  4. 安装mysql报错

    原文链接:https://blog.csdn.net/bao19901210/article/details/51917641 二进制安装 1.添加mysql组和mysql用户,用于设置mysql安装 ...

  5. PHP连接MySQL报错:SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2)

    如下所示,PHP连接MySQL报错: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' ...

  6. 【mysql的编程专题⑤】自定义函数

    用户自定义函数(user-defined function,UDF) 是一种对mysql的扩展途径,其用法与内置函数相同 创建自定义函数 语法 create function function_nam ...

  7. 解决:MySQL 报错:1045 - Access denied for user 'root'@'localhost'(using password YES)

    一.前言 今年疯狂迷上了开源,只要看到好的开源项目,就会不顾一切一股脑扎进去研究,五一期间发现一个很好的关于众筹的开源项目,但不巧,这个项目竟然是 PHP 写的,没学过 PHP,自然对这个开源项目毫无 ...

  8. MySQL报错ERROR 1558 (HY000): Column count of mysql.user is wrong.

    MySQL报错ERROR 1558 (HY000): Column count of mysql.user is wrong. 1.今天在使用MySQL创建数据库时出现如下报错: mysql> ...

  9. Mysql报错java.sql.SQLException:null,message from server:"Host '27,45,38,132' is not allowed to connect

    Mysql报错java.sql.SQLException:null,message from server:"Host '27,45,38,132' is not allowed to co ...

随机推荐

  1. UVA 10537 The Toll! Revisited 过路费(最短路,经典变形)

    题意:给一个无向图,要从起点s运送一批货物到达终点e,每个点代表城镇/乡村,经过城镇需要留下(num+19)/20的货物,而经过乡村只需要1货物即可.现在如果要让p货物到达e,那么从起点出发最少要准备 ...

  2. 05day2

    05day1 没什么可说,一道模拟水题,两道裸的模板题.05day2 是几天以来最难的一次.   圆排列 动态规划 [问题描述] 有 N 个人顺时针围在一圆桌上开会,他们对身高很敏感. 因此决定想使得 ...

  3. P2P直播、点播技术学习经验

    自8月份以来一直埋头学习P2P在音/视频直播.点播上的学习,受到不少网友的帮助,在此也留下自己学到的一点点的经验. 第一个接触的开源项目是peercast,应该说上手非常快,这必须感谢王浩聪的注释版, ...

  4. 常见MyEclipse报错—— serialVersionUID的作用

    先挖好坑 http://swiftlet.net/archives/1268

  5. JOB的创建,定时,执行

    --建表 create table test_job(para_date date);  commit;  insert into test_job values(sysdate);  commit; ...

  6. 【c++内存分布系列】虚基类表

    虚基类表相对于虚函数表要稍微难理解些,故单独提出来. 虚函数表是在对象生成时插入一个虚函数指针,指向虚函数表,这个表中所列就是虚函数. 虚基类表原理与虚函数表类似,不过虚基类表的内容有所不同.表的第一 ...

  7. Delphi RichEx 图像

    unit RichEx; {2005-03-04 LiChengbinAdded:Insert bitmap or gif into RichEdit controls from source fil ...

  8. Authentication with SignalR and OAuth Bearer Token

    Authentication with SignalR and OAuth Bearer Token Authenticating connections to SignalR is not as e ...

  9. PHP Module中获取$_GET/$_POST/$_COOKIE的方法研究

    假设要获取$_GET['c']; 首先,先介绍下http_globals; 1.http_globals,定义在php_globals.h中: zval * http_globals[6]; 其中的索 ...

  10. DOS功能的调用

    DOS功能的调用:主要包含三方面的子程序:设备驱动(基本I/O),文件管理和其他(包括内存管理,自取时间,自取终端向量,总之程序等)随着DOS版本的升级,这种DOS功能调用的子程序数量也在不断的增加, ...