在MySQL8.0.19上创建函数,报错:
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)
原因:未开启函数功能。
查询:show variables like '%func%';
如下图:
开启函数功能:set global log_bin_trust_function_creators=1;
再次查询,如下图:
这样,就可以创建函数了。
备注:这个动态设置的方式会在服务重启后失效。因此,要在my.ini配置文件中加上该配置log_bin_trust_function_creators=1。