CentOS7 下调教mysql记实 之一

迁移数据库时遇到错误:

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)

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

解决办法:

在CentOS终端上运行:
# mysql -uroot -p你的密码

MariaDB [(none)]> show variables like '%func%';

+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)


MariaDB [(none)]> set global log_bin_trust_function_creators=1;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)

 

通过 set global log_bin_trust_function_creators=1; 的设置,在重启后失效。永久办法:

windows下my.ini
[mysqld]加上log_bin_trust_function_creators=1   linux下/etc/my.cnf下my.cnf

[mysqld]加上log_bin_trust_function_creators=1

 

转载于:https://www.cnblogs.com/dreamfine/p/6881751.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值