【MySQL案例】ERROR 1418

1.1.1. ERROR 1418

【环境描述】

mysql5.0.67

【问题描述】

创建存储过程的时候遇到ERROR 1418报错。

# 创建函数的SQL语句

CREATE FUNCTION `xxx`( num01 int ) RETURNSint(11)

begin

declare mm  int default 0;

if  (xx) then

set mm = num01*num01*10;

elseif  xxx then

set mm = 10;

else

case num01

when  30 then set mm = 111;

when  31 then set mm = 222;

end case;

end if;

return mm;

end

# 报错信息

# ERROR 1418 (HY000) at line xxxxx: Thisfunction has none of DETERMINISTIC, NO SQL, or READS SQL DATA in itsdeclaration and binary logging is enabled (you *might* want to use the lesssafe log_bin_trust_function_creators variable)

【解决方法】

关闭关闭binary log或者修改参数。

此处采用修改参数的方法:

set globallog_bin_trust_function_creators=1;

【报错原因】

By default, for a CREATE FUNCTION
statement to be accepted, at least one of
DETERMINISTIC,
NOSQL, or READS SQL DATA
must be specified explicitly. Otherwise an error occurs:

ERROR1418 (HY000): This function has none of DETERMINISTIC, NO SQL,

or READSSQL DATA in its declaration and binary logging is enabled

(you*might* want to use the less safe log_bin_trust_function_creators

variable)

If you set log_bin_trust_function_creators
to 1, the requirement that functions be

deterministic or not modify data is dropped.

【参考资料】

Command-LineFormat --log-bin-trust-function-creators

Option-FileFormat log-bin-trust-function-creators

SystemVariable Name log_bin_trust_function_creators

VariableScope Global

DynamicVariable Yes

PermittedValues

Type boolean

Default FALSE

This variable applieswhen binary logging is enabled. It controls whether stored function creators canbe trusted not to create stored functions that will cause unsafe events to bewritten to the binary log. If set to
0 (the default), users are not permittedto create or alter stored functions unless they have the
SUPER privilege in addition to the
CREATE ROUTINE or
ALTER ROUTINE privilege. A setting of0 also enforces the restriction that a function must be declared with the
DETERMINISTIC characteristic, or with the
READS SQL DATA or
NO SQL characteristic. If the variable is set to 1, MySQLdoes not enforce these restrictions on stored function creation. This variablealso applies to trigger creation. See
Section19.7, “Binary Logging of Stored Programs”.

【MySQL案例】ERROR 1418

时间: 2024-08-17 18:20:40

【MySQL案例】ERROR 1418的相关文章

【MySQL案例】error.log的Warning:If a crash happens thisconfiguration does not guarantee that the relay lo

1.1.1. If a crash happens thisconfiguration does not guarantee that the relay log info will be consistent [环境描述] msyql5.6.14 [报错信息] mysql的slave启动时,error.log中出现Warning警告: [Warning] Slave SQL: If a crash happensthis configuration does not guarantee tha

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

【MySQL案例】ERROR 1786 (HY000)

1.1.1. ERROR 1786 (HY000) [环境描述] msyql5.6.14 [报错信息] 执行create table ... select的时候遇到报错: db1 [test] [23:01:58]> create tablelgmnr_bak select * from lgmnr; ERROR 1786 (HY000): CREATE TABLE ... SELECTis forbidden when @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1

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

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

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

【MySQL案例】ERROR 1665 (HY000)

1.1.1. ERROR 1665 (HY000) [环境描述] msyql5.6.14 [报错信息] 执行SQL语句的时候报错: ERROR 1665 (HY000): Cannot executestatement: impossible to write to binary log since BINLOG_FORMAT = STATEMENTand at least one table uses a storage engine limited to row-based logging.

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

UCenter info: MySQL Query Error的解决方法----For Discuz!

备注: 出现这个问题同时会造成论坛注册,登录和发帖时等页面无法跳转(APP1运行不正常) 案例: UCenter info: MySQL Query Error SQL:SELECT * FROM [Table]notelist WHEREclosed='0' AND app1<'1' AND app1>'-5' LIMIT 1 Error:Unknown column 'app1' in 'whereclause' Errno:1054 分析: 错误是说在UCenter数据库的notelis

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