首頁  >  文章  >  資料庫  >  解決mysql報錯This function has none of DETERMINISTIC問題

解決mysql報錯This function has none of DETERMINISTIC問題

藏色散人
藏色散人轉載
2021-06-04 11:49:034174瀏覽

本篇文章跟大家介紹一下mysql 報錯This function has none of DETERMINISTIC解決方案。有一定的參考價值,有需要的朋友可以參考一下,希望對大家有幫助。

本文向朋友介紹開啟bin-log日誌mysql報錯: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 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指定一個參數。

解決方法:

SQL code
mysql> show variables like 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name          | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF  |
+---------------------------------+-------+
mysql> set global log_bin_trust_function_creators=1;
mysql> show variables like 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name          | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON  |

這樣加入了參數以後,如果mysqld重啟,那個參數又會消失,因此記得在my.cnf設定檔中加入:

log_bin_trust_function_creators=1

推薦:《mysql影片教學

以上是解決mysql報錯This function has none of DETERMINISTIC問題的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:jb51.net。如有侵權,請聯絡admin@php.cn刪除