您的位置:首页 > 数据库 > MySQL

Mysql:开启了log-bin的MySQL Server中创建FUNCTION

2018-01-13 14:48 495 查看

1.错误信息

在开启了bin-log模式的Mysql服务中,创建Function失败。

Error Code: 1418. 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)


2.原因分析

在主从复制的两台MySQL服务器中开启了二进制日志选项log-bin,slave会从master复制数据,而一些操作,比如function所得的结果在master和slave上可能不同,所以存在潜在的安全隐患。因此,在默认情况下Mysql会阻止function的创建。

3.解决问题

这里提供两种方式:

3.1. mysql> set global log_bin_trust_function_creators=1;

在mysql服务中执行
set global log_bin_trust_function_creators=1;


这种方式只是在当前Mysql运行期间有效,Mysql服务重启失效。

3.2. > vim /etc/my.cnf

在my.cnf(或my.ini)中添加配置项
log-bin-trust-function-creators


> service mysqld stop
> vim /etc/my.cnf

[mysqld]
log-bin-trust-function-creators = 1

> Service mysqld start
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql binary logs function