MySQL建立Function時報的1418錯誤代號解決辦法

來源:互聯網
上載者:User

以下是引用片段:
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;

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.