The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL problem. Using CREATE FUNCTION

Discussion in 'General Discussion' started by Svintoo, Apr 17, 2009.

  1. Svintoo

    Svintoo Member

    Joined:
    Apr 16, 2009
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    I have a problem when one of my customers tries to create his own sql example function.
    According to the MySQL manual the only privileges needed to do so is the CREATE ROUTINE privilege. The ALTER ROUTINE and EXECUTE privileges will be granted automatically (see http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html).

    The problem is the MySQL fails to grant the ALTER ROUTINE and EXECUTE privileges:
    Code:
    MySQL (***@***.**): 2009-04-17 15:41:47: 1404: Failed to grant EXECUTE and ALTER ROUTINE privileges
    MySQL (***@***.**): 2009-04-17 15:41:47: 1410: You are not allowed to create a user with GRANT
    It seems MySQL tries to do something in the background that is not mentioned in the manual. I think it may be something with MySQL not supporting user privileges to different databases and CPanel uses a workaround for this (by forcing db and dbuser names to contain the CPanel username).

    Does someone have a clue?
    Is it possible to create your own functions in MySQL under CPanel or is it impossible with how it is implemented?

    The customers test code:
    Code:
    CREATE FUNCTION [mysql-username].WEIGHTED_AVERAGE (
    	n1 INT,
    	n2 INT,
    	n3 INT,
    	n4 INT
    )
    RETURNS INT
    DETERMINISTIC
    
    BEGIN
    	DECLARE avg INT;
    	SET avg = (n1+n2+n3*2+n4*4)/8;
    	RETURN avg
    END
     
    #1 Svintoo, Apr 17, 2009
    Last edited: Apr 24, 2009
  2. tuxicans

    tuxicans Active Member

    Joined:
    Oct 16, 2008
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    cPanel mysql management does not have a privilege ROUTINE in its list of privileges. Please contact your hosting support team to add this privilege for the database user from server backend.
     
Loading...

Share This Page