MySQL常见错误处理方法

1. ERROR 1418

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)

分析:根据系统提示,导致该错误的原因可能是一个安全设置方面的配置,查手册log_bin_trust_function_creators参数缺省0,是不允许function的同步的,一般我们在配置repliaction的时候,都忘记关注这个参数,这样在master更新funtion后,slave就 会报告错误,然后slave stoped。

解决办法:

mysql> set global log_bin_trust_function_creators = true;
mysql> create function avg_age(s varchar(5))
    ->  returns int
    ->  begin
    ->          return (select age from t_emp where name = s);
    ->  end $
Query OK, 0 rows affected (0.01 sec)

 

posted @ 2022-04-23 21:16  熊猫怪物  阅读(37)  评论(0)    收藏  举报