MariaDB [hellodb]> create function simpleFun() returns varchar(20) return "hello world!";
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)
这里由于启用了二进制日志,提示创建时需指定函数类型DETERMINISTIC, NO SQL, READS SQL DATA,或者启用变量log_bin_trust_function_creators,如下:
MariaDB [(none)]> set global log_bin_trust_function_creators=on;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
也可以写入my.cnf配置文件中并重启数据库。