建立存儲過程時mysql
出錯信息: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)less
緣由:函數
這是咱們開啓了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指定一個參數。code
解決方法:it
SQL codeio
mysql> show variables like 'log_bin_trust_function_creators';function
+---------------------------------+-------+配置
| Variable_name | Value |rust
+---------------------------------+-------+
| 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