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. 常用的math函数

    <?php    //1.abs — 绝对值                      echo abs(-77);      //ceil — 进一法取整                   ...

  2. python INFO: Can't locate Tcl/Tk libs and/or headers

    安装opencv的时候遇到这个错误: python INFO: Can't locate Tcl/Tk libs and/or headers 参考如下文章解决这个问题: http://www.ver ...

  3. masonry插件和infinitescroll插件实现无刷新无分页完美瀑布流

    地址有:http://www.17sucai.com/pins/2657.html 如果你善于发现美,如果你善于观察新鲜的事物,如果你是一名有爱的前端攻城师或设计尸,那么你一定不会对下面图片中的结构感 ...

  4. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

  5. 2016 Al-Baath University Training Camp Contest-1 B

    Description A group of junior programmers are attending an advanced programming camp, where they lea ...

  6. 一致性hash算法——之二

    摘自:http://www.tomkleinpeter.com/2008/03/17/programmers-toolbox-part-3-consistent-hashing/

  7. Win7\xp添加虚拟网Microsoft Loopback Adapter

    安装Microsoft Loopback Adapter 1 依次找到 打开“开始菜单”---“控制面板”---“添加硬件”的菜单选项如下图所示. 步骤阅读 2 如果没有“添加硬件”当然你也可以直接, ...

  8. SqlSever基础 except 差集 前一个结果中不含有后一个结果的元素

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  9. HTML(Open Method)翻译自MSDN

    Open Method Opens a new window and loads the document specified by a given URL. Navigates the app wi ...

  10. TeeChart曲线平滑 Line.Smoothed

    需要注意的是,在加载点之前,需要设置Smoothed属性为false 等点加载完成之后,再设置Smoothed属性为true, //如果直接设置Smoothed为true再去加载点的话,曲线就完全不显 ...