[Problem] How to Create a function in MySQL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.