mysql中创建函数时报错信息

报错信息如下

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

错误分析

我们创建函数时必须指定我们的函数是否是

  1. DETERMINISTIC 不确定的
  2. NO SQL 没有SQl语句,当然也不会修改数据
  3. READS SQL DATA 只是读取数据,当然也不会修改数据
  4. MODIFIES SQL DATA 要修改数据
  5. CONTAINS SQL 包含了SQL语句

解决方案

在MySQL中创建函数时出现这种错误的解决方法:

在mysql数据库中执行以下语句 (临时生效,重启后失效)

set global log_bin_trust_function_creators=TRUE;

在配置文件/etc/my.cnf的[mysqld]配置log_bin_trust_function_creators=1

vim /etc/my.cnf
log_bin_trust_function_creators=1
posted @ 2022-02-02 23:48  咚咚小孩  阅读(139)  评论(0)    收藏  举报