ERROR 1418 (HY000) at line 639: 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服務器中開啓了二進制日誌選項log-bin,slave會從master複製數據,而一些操做,好比function所得的結果在master和slave上可能不一樣,因此存在潛在的安全隱患。所以,在默認狀況下回阻止function的建立。mysql
mysql> show variables like 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+sql
mysql> set global log_bin_trust_function_creators=1;vim
或vim /etc/my.cnf
log_bin_trust_function_creators=1安全