Mysql ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA

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

时间: 2024-12-23 13:03:11

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

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 DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)ERROR 1418 (HY000

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

今天创建function CREATE FUNCTION `func_get_split_string_total`( f_string varchar(1000),f_delimiter varchar(5) ) RETURNS int(11) BEGIN return 1+(length(f_string) - length(replace(f_string,f_delimiter,''))); END 报错信息: ERROR 1418 (HY000): This function has

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

创建function时 出错信息: 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) 原因: 这是我们开启了bin-

This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA

This function has none of DETERMINISTIC, NO SQL解决办法            2011-12-01 14:07:01 This function has none of DETERMINISTIC, NO SQL解决办法 创建存储过程时 出错信息: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declara

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 DETERMINISTIC, NO SQL解决办法 创建存储过程时 出错信息: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging i

mysql error 1418 解决方法

声明 作者:昨夜星辰 博客:http://yestreenstars.blog.51cto.com/ 本文由本人创作,如需转载,请注明出处,谢谢合作! 错误 ERROR 1418 (HY000) at line 1693: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to u

Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled...

Error Code: 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]ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

From: http://m.blog.csdn.net/blog/langkeziju/13511411 我的MySQL版本为5.6.14版本,是二进制包安装的(虽然是二进制包安装的,但是以下问题同样适用于源码安装包安装的MySQL) 今天在我的测试库上添加一个新用户,报错: [[email protected] ~]$ mysql -uroot -p123456 Warning: Using a password on the command line interface can be in

mysql ERROR 126 (HY000): Incorrect key file for table '/tmp/#sql_1d87_0.MYI'; try to repair it

[[email protected] ~]# df -h 查看是否空间不足 在查看mysql数据目录情况 mysql> show variables like '%dir%'; +-----------------------------------------+------------------------------------+ | Variable_name                           | Value                              |