<pre name="code" class="html">set global log_bin_trust_function_creators=TRUE; delimiter $$ CREATE DEFINER=`zjzc_app`@`%` FUNCTION `loadTreeByParent`(begin_sn INT) RETURNS varchar(600) CHARSET utf8 BEGIN DECLARE rest VARCHAR(600); DECLARE temp VARCHAR(60); SET rest='$'; SET temp=CAST(begin_sn AS CHAR); WHILE temp IS NOT NULL DO SET rest=CONCAT(rest,',',temp); SELECT GROUP_CONCAT(sn) INTO temp FROM ClientManager WHERE FIND_IN_SET(parent,temp)>0; END WHILE; RETURN rest; END$$ This variable applies when binary logging is enabled. It controls whether stored function creators can be trusted not to create stored functions that will cause unsafe events to be written to the binary log. If set to 0 (the default), users are not permitted to create or alter stored functions unless they have the SUPER privilege in addition to the CREATE ROUTINE or ALTER ROUTINE privilege. A setting of 0 also enforces the restriction that a function must be declared with the DETERMINISTIC characteristic, or with the READS SQL DATA or NO SQL characteristic. If the variable is set to 1, MySQL does not enforce these restrictions on stored function creation. This variable also applies to trigger creation. See Section 20.7, “Binary Logging of Stored Programs”. 这个变量应用当binary logging 被启用,它控制是否存储函数创建者可以被信任不是 创建函数 会影响不安全的事件被写入到binary log. 如果设置为0 默认情况下, 用户不允许创建或者修改存储过程除非它们有SUPER 权限 除了CREATE ROUTINE or ALTER ROUTINE 的权限。 设置为0也强制限制一个函数必须被定义DETERMINISTIC字符,或者 READS SQL DATA or NO SQL characteristic. 如果变量设置为1 MySQL 不强制那些限制在存储函数创建,这个变量也适用于触发器创建 [root@zjzc01 ~]# cat t1.sql set global log_bin_trust_function_creators=TRUE; delimiter $$ CREATE DEFINER=`zjzc_app`@`%` FUNCTION `loadTreeByParent`(begin_sn INT) RETURNS varchar(600) CHARSET utf8 BEGIN DECLARE rest VARCHAR(600); DECLARE temp VARCHAR(60); SET rest='$'; SET temp=CAST(begin_sn AS CHAR); WHILE temp IS NOT NULL DO SET rest=CONCAT(rest,',',temp); SELECT GROUP_CONCAT(sn) INTO temp FROM ClientManager WHERE FIND_IN_SET(parent,temp)>0; END WHILE; RETURN rest; END$$ mysql> show create FUNCTION loadTreeByParent; mysql> use zjzc; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> source t1.sql Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> quit | loadTreeByParent | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`zjzc_app`@`%` FUNCTION `loadTreeByParent`(begin_sn INT) RETURNS varchar(600) CHARSET utf8 BEGIN DECLARE rest VARCHAR(600); DECLARE temp VARCHAR(60); SET rest='$'; SET temp=CAST(begin_sn AS CHAR); WHILE temp IS NOT NULL DO SET rest=CONCAT(rest,',',temp); SELECT GROUP_CONCAT(sn) INTO temp FROM ClientManager WHERE FIND_IN_SET(parent,temp)>0; END WHILE; RETURN rest; 默认OFF: mysql> show variables like '%log_bin_trust_function_creators%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | log_bin_trust_function_creators | OFF | +---------------------------------+-------+ 1 row in set (0.00 sec) my.cnf 文件添加: log_bin_trust_function_creators=1 owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> show variables like '%log_bin_trust_function_creators%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | log_bin_trust_function_creators | ON | +---------------------------------+-------+ 1 row in set (0.01 sec)