Creating functions in phpMyAdmin – Error: access denied you need the super privilege for this operation

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.

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”.

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

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 */;;

Leave a Comment