在mysql创建自定义函数的时候,有时候会报以下错误:
Error Code: 1418. 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)
这时候只要在运行创建函数的代码之前运行
set global log_bin_trust_function_creators = 1
当然,只有在开启了log-bin(mysql二进制日志)才会出现这种情况,如果没有开启log-bin则不会出现这种报错