建站百科Website News

当前位置:首页 »MySQL创建函数时1418错误代码解决方案

MySQL创建函数时1418错误代码解决方案

至成科技2015-02-03访问量(2834)评论(0)
摘要:
以下是引用片段:
ErrorCode:1418
ThisfunctionhasnoneofDETERMINISTIC,NOSQL,orREADSSQLDATAinitsdeclarationandbinaryloggingisenabled(you*might*wanttousethelesssafelog_bin_trust_function_creatorsvariable)
(0mstaken)

  解决方法如下:

  1. mysql> SET GLOBAL log_bin_trust_function_creators = 1;

  2. 系统启动时 --log-bin-trust-function-creators=1

  3. 在my.ini(linux下为my.conf)文件中 [mysqld] 标记后加一行内容为 log-bin-trust-function-creators

如果在create function的时候有 1418的错语的时候:那么只需要执行set global log_bin_trust_routine_creators=1;

然后怎么create function 都不会有问题(当然,你的function必段正确哦),这是mysql的一个bug,搞不懂为什么,反正这样做就OK了.

另外,也可以直接在配置文件my.cnf中添加如下行[mysqld] log_bin_trust_routine_creators=1;

这个命令可以在sql editor的环境中运行,并不需要重新启动服务哦。

MySQL自5.0之后终于支援SP( Store Procedures ),
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) Assessment of the nature of a function is based on the “honesty” of the creator: MySQL does not check that a function declared DETERMINISTIC is free of statements that produce non-deterministic results.

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.
1. mysql> SET GLOBAL log_bin_trust_function_creators = 1;
2. 系统启动时,加上--log-bin-trust-function-creators 参数为1
3. 直接在my.ini的[mysqld]区段加上log-bin-trust-function-creators=1
当然我想大多数人会用第三种方法,
ok...继续我的SP学习,good luck..

二、mysql ERROR 1418 (HY000)

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-log, 我们就必须指定我们的函数是否是
1 DETERMINISTIC 不确定的
2 NO SQL 没有SQl语句,当然也不会修改数据
3 READS SQL DATA 只是读取数据,当然也不会修改数据
4 MODIFIES SQL DATA 要修改数据
5 CONTAINS SQL 包含了SQL语句


其中在function里面,只有 DETERMINISTIC, NO SQL 和   READS SQL DATA 被支持。如果我们开启了 bin-log, 我们就必须为我们的function指定一个参数。

我们可以通过设置如下的参数来关掉这个。

SET GLOBAL log_bin_trust_function_creators = 1;

    以上内容由至成科技西安网站建设为您提供,更多精彩内容:http://www.xazcit.com/


扫描左侧二维码
关注至成微信公众号

西安至成信息科技有限公司  Copyright 2012-2025  xazcit.com  All rights reserved.

Email:zcit@zcit.net     邮政编码:710016     《中华人民共和国增值电信业务经营许可证》陕B1.B2-20140011     陕ICP备12008874号-1

联系地址:西安市经开区凤城四路西安国际企业中心B座23层06-10室    售前咨询热线:02989390727    售后服务电话:02989390727

西安网站建设、网站设计制作公司-至成科技,已为众多企业提供网站建设网站制作响应式网站设计手机网站建设虚拟主机云主机服务器租用等建站解决方案。

域名合作伙伴:新网互联软件服务有限公司 陕公网安备 61019102000393号

网络警察12321垃圾信息举报不良信息举报中国文明网西安工商高新技术企业证书