且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在phpMyAdmin中创建函数-错误:访问被拒绝,您需要此操作的超级权限

更新时间:2021-12-23 21:58:13

问题是我没有超级特权,但是如果我从查询中删除DEFINER,就不再需要此特权.

The problem was I didn't have the super privilege but if I remove the DEFINER from the query I don't need this privilege anymore.

从MySQL 5.0.3开始,CREATE PROCEDURE和CREATE FUNCTION需要 创建例程特权.他们可能还需要SUPER特权, 取决于DEFINER值,如本节后面所述.如果 启用二进制日志记录,CREATE FUNCTION可能需要SUPER 特权,如第18.6节存储的二进制日志"中所述 程序".

As of MySQL 5.0.3, CREATE PROCEDURE and CREATE FUNCTION require the CREATE ROUTINE privilege. They might also require the SUPER privilege, depending on the DEFINER value, as described later in this section. If binary logging is enabled, CREATE FUNCTION might require the SUPER privilege, as described in Section 18.6, "Binary Logging of Stored Programs".

还必须在SQL文本框下设置定界符字段.

Also had to set the delimiter field under the SQL text box.

这是不带DEFINER语句的SQL查询:

Here's the SQL Query without the DEFINER statement:

/*!50003 DROP FUNCTION IF EXISTS `f_calc_gst` */;;
/*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50003 FUNCTION `f_calc_gst`(p_ht decimal(15,3), p_province varchar(2)) RETURNS varchar(255) CHARSET utf8
begin
  declare res varchar(255); 
  declare v_gst decimal(15,3);
  declare v_gst_formula varchar(255);

  select GST, GST_formula
  into v_gst, v_gst_formula
  from taxes_periods
  where NOW() between dt_debut and dt_fin
  and id_province = p_province;

  set v_gst_formula = replace(v_gst_formula, 'HT$', p_ht);
  set v_gst_formula = replace(v_gst_formula, 'GST%', v_gst);

  set res = concat('select round(', v_gst_formula, ',2) "gst"');
  return res;
end */;;