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)
错误的原因:
Mysql配置了复制,复制功能也就意味着Master数据的变化,会同步到Slave。对于函数,Mysql要求函数不能修改数据。
解决办法:
1、创建函数的时候,明确说明我不会修改数据。创建函数的时候有5个选项:
a、DETERMINISTIC 确定性的
b、NO SQL 没有包含SQl语句,当然也不会修改数据
c、READS SQL DATA 只是读取数据,当然也不会修改数据
d、MODIFIES SQL DATA 要修改数据
e、CONTAINS SQL 包含了SQL语句
怎么理解DETERMINISTIC确定性的?
可以认为输入相同,方法执行过程,输出也是相同的。也就是方法的可重入性。不可重入的方法:方法内使用了静态的数据,使用了malloc和free,使用了标准I/O函数。
创建函数必须明确指出a、b、c三个选项中的一个,才能执行成功。如下:
mysql> show variables like 'log_bin%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| log_bin                         | ON    |
| log_bin_trust_function_creators | OFF   |
| log_bin_trust_routine_creators  | OFF   |
+---------------------------------+-------+
3 rows in set
mysql> create function fun1 (num int(9)) returns int(9)
begin
return 1;
end;
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)
mysql> create function fun1 (num int(9)) returns int(9) reads sql data
begin
return 1;
end;
Query OK, 0 rows affected
mysql> drop function fun1;
Query OK, 0 rows affected
mysql> create function fun1 (num int(9)) returns int(9) deterministic
begin
return 1;
end;
Query OK, 0 rows affected
2、告诉Mysql,信任我,方法不会修改数据,Mysql不再检查,即使修改了数据。这个时候要靠你信守承诺,否则后果自负。
mysql> drop function fun1;
Query OK, 0 rows affected
mysql> set global log_bin_trust_function_creators=on;
Query OK, 0 rows affected
mysql> show variables like 'log_bin%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| log_bin                         | ON    |
| log_bin_trust_function_creators | ON    |
| log_bin_trust_routine_creators  | ON    |
+---------------------------------+-------+
3 rows in set
mysql> create function fun1 (num int(9)) returns int(9) modifies sql data
begin
return 1;
end;
Query OK, 0 rows affected

Mysql ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA的更多相关文章

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

  2. mysql 报错:ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA

    解决办法:设置临时环境变量 ;  

  3. Mysql自定义函数之------------This function has none of DETERMINISTIC, NO SQL解决办法

    This function has none of DETERMINISTIC, NO SQL解决办法 创建存储过程时 出错信息: ERROR 1418 (HY000): This function ...

  4. MySQL创建方法错误:This function has none of DETERMINISTIC, NO SQL

    创建function时 出错信息: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL ...

  5. this function has none of deterministic, no sql,or reads sql data in its declaration and binary logging is enabled

      原址:http://blog.chinaunix.net/uid-20639775-id-3031821.html   This function has none of DETERMINISTI ...

  6. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary lo的解决办法

    创建存储过程时,出错信息: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA ...

  7. Linux MySQl 5.7.17 MySQL ERROR 1366(HY000):Incorrect string value 解决方法

    MySQL ERROR 1366(HY000):Incorrect string value,在往数据库中插入中文的时候会出现. 这也就是编码问题,网上大部分都是说设置下配置文件中的设置,而可悲的是在 ...

  8. MySQL:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    解决方法: 修改密码:alter user 'root'@'localhost' identified by '123456'; mysql> use mysql; ERROR 1820 (HY ...

  9. mysql - ERROR 1114 (HY000): The table is full

    mysql - ERROR 1114 (HY000): The table is full - Stack Overflowhttps://stackoverflow.com/questions/73 ...

随机推荐

  1. hdu 1061 Rightmost Digit

    解决本题使用数学中的快速幂取余: 该方法总结挺好的:具体参考http://www.cnblogs.com/PegasusWang/archive/2013/03/13/2958150.html #in ...

  2. Channel Allocation

    Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13231 Accepted: 6774 D ...

  3. A Plug for UNIX 分类: POJ 图论 函数 2015-08-10 14:18 2人阅读 评论(0) 收藏

    A Plug for UNIX Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14786 Accepted: 4994 Desc ...

  4. SIGPIPE信号详解

    转自:http://blog.csdn.net/lmh12506/article/details/8457772 前一段面试的时候被问到项目中有没有处理SIGPIPE信号,怎么处理的?当时没有答出来, ...

  5. volatile关键字解析

    转载:http://www.cnblogs.com/dolphin0520/p/3920373.html volatile这个关键字可能很多朋友都听说过,或许也都用过.在Java 5之前,它是一个备受 ...

  6. 关于Filter的配置

    配置代码: <filter> <display-name>OneFilter</display-name>  <filter-name>OneFilte ...

  7. sorl维护索引库sorl4j的使用

    1.维护索引库 添加:添加一个json格式的文件就可以. 修改:在solr中没有update,只需要添加一个新的文档,要求文档id和被修改文档的id一致.原理是先删除后添加. 删除:使用xml格式. ...

  8. key可以重复的Map集合:IdentityHashMap

    所有Map操作中key的值是不能重复的,例如,HashMap操作时key是不能重复的,如果重复则肯定会覆盖之前的内容,如下代码所示. 范例:Map中的key不允许重复,重复就是覆盖 package o ...

  9. Codeforces Round #370 (Div. 2) A

    Description There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai ...

  10. DateFormat 中间加别的字符

    private static DateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");