问题描述
mysql函数保存时,出现下面的错误
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)
问题分析
由于mysql数据库开启了binlog日志,又因为在binlog开启的状态下,系统默认在binlog开启的时候是关闭生成函数
的使用的。这是因为系统需要信任生成函数,如果某天需要通过binlog日志回滚,而所有事务里就带有某些损害系统的函数,那么就可以提桶跑路了。
问题解决
1.查看log_bin_trust_function_creators变量值
值是off将不能执行生产函数,只有值为on的时候可以执行生产函数
2.临时设置MySQL的变量的值
注意:重启服务后此变量的变量值将会变为off
set global log_bin_trust_function_creators=1;
3.永久设置MySQL的变量的值
写入配置文件的变量和变量值不会随服务重启而失效,永久有效
在mysql配置文件中(windows为my.ini,linux为my.cnf)增加一行配置,然后要重启mysql实例!
# 1代表on,0代表off
log_bin_trust_function_creators=1