From: http://www.uini.net/2010/03/mysql-create-function-problem.html
Http://blog.csdn.net/wuhuiran/archive/2007/12/14/1935220.aspx
During data sorting today, I encountered the problem that MySQL functions cannot be created. I have encountered this problem many times before. The solution is a solution, but the solution is always hard to remember and cannot be well written down, so that every time I had to Google again, it took a lot of time and effort, and this time I finally couldn't stand it, but I chose to write it out:
The error information is similar to the following:
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)
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)
No function can be created, but the function is not enabled:
MySQL > Show Variables Like ' % Func % ' ;
+ -- ------------------------------- + ------- +
| Variable_name | Value |
+ -- ------------------------------- + ------- +
| Log_bin_trust_function_creators | Off |
+ -- ------------------------------- + ------- +
1 Row In Set ( 0.00 Sec)
MySQL > Set Global log_bin_trust_function_creators = 1 ;
Query OK, 0 Rows affected ( 0.00 Sec)
MySQL > Show Variables Like ' % Func % ' ;
+ -- ------------------------------- + ------- +
| Variable_name | Value |
+ -- ------------------------------- + ------- +
| Log_bin_trust_function_creators | On |
+ -- ------------------------------- + ------- +
1 Row In Set ( 0.00 Sec)
We can also add the following sentence to mysqld in the my. ini file:
[Mysqld]
Log-bin = c: \ Program Files \ mysql \ MySQL Server 5.1 \ log \ log-bin.log -- generate log files
Log-bin-trust-function-creators = 1 -- function enabled