我们在使用mysql数据库开发项目的时候,有时Mysql系统自带的函数不能完全满足我们开发的需要,解决方法是自己创建函数,可以有可能在你创建函数的过程事会报出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)
解决方法:MySQL函数不能创建,是未开启功能:
mysql> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql> set global log_bin_trust_function_creators=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)mysql>
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql> set global log_bin_trust_function_creators=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)mysql>
如果上方法不能成功解决mysql中的ERROR 1418错误,那还得请你使用下面方法试试:
1方式: mysql> SET GLOBAL log_bin_trust_function_creators = 1;
2方式: 系统启动时 --log-bin-trust-function-creators=1
3方式: 在my.ini(Linux下为my.conf)文件中 [mysqld] 标记后加一行内容为 log-bin-trust-function-creators=1