39

Hello, I am currently having an issue with MySQL!

What's going wrong here? I am a cPanel user, and yes I have searched this and found no definitive answers. It appears this is more specific than other people with the same error codes issues. Please add a detailed response that I can follow along with! P.s I am using a shared hosting account.

DELIMITER $$--
-- Functions
--
CREATE DEFINER =  `root`@`localhost` FUNCTION  `fnc_calcWalkedDistance` (

`steamid64` BIGINT UNSIGNED
) RETURNS INT( 10 ) UNSIGNEDNO SQL BEGIN DECLARE finished INTEGER DEFAULT 0;

DECLARE distance INTEGER DEFAULT 0;

DECLARE x1, x2, z1, z2 FLOAT;

DECLARE curs CURSOR FOR SELECT x, z
FROM log_positions
WHERE  `steamid` = steamid64
ORDER BY  `timestamp` DESC ;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished =1;

OPEN curs;

FETCH curs INTO x1, z1;

SET x2 = x1;

SET z2 = z1;

calculate : LOOPFETCH curs INTO x1, z1;

IF finished =1 THEN LEAVE calculate;

END IF ;

SET distance = distance + SQRT( POW( x2 - x1, 2 ) + POW( z2 - z1, 2 ) ) ;

-- SET distance = distance + 1;
SET x2 = x1;

SET z2 = z1;

END LOOP calculate;

CLOSE curs;

RETURN distance;

END$$

Here is the error code:

MySQL said: Documentation

#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation 
Lachie
  • 1,321
  • 1
  • 10
  • 26

6 Answers6

81

It means you don't have privileges to create the trigger with root@localhost user..

try removing definer from the trigger command:

CREATE DEFINER = root@localhost FUNCTION fnc_calcWalkedDistance

Aman Aggarwal
  • 17,619
  • 9
  • 53
  • 81
38

Simply remove "DEFINER=your user name@localhost" and run the SQL from phpmyadminwill works fine.

Shafiq
  • 963
  • 8
  • 4
22

In case you are uploading an sql file on cpanel, then try and replace root with your cpanel username in your sql file.

in the case above you could write

CREATE DEFINER = control_panel_username@localhost FUNCTION fnc_calcWalkedDistance

then upload the file. Hope it helps

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
Junior_swashluv
  • 301
  • 2
  • 4
6

remove DEFINER=root@localhost from all calls including procedures

Muhammad Waqas
  • 511
  • 6
  • 9
0

Change

CREATE DEFINER =  `root`@`localhost` FUNCTION  `fnc_calcWalkedDistance` (

By

FUNCTION  `fnc_calcWalkedDistance` (
0

Either remove the line CREATE DEFINER = root@localhost or change it to CREATE DEFINER = <mysqluser>@<mysqlhost>

If you delete the DEFINER attribute, the default will be the current user account.

Note: DEFINER is an optional attribute for defining a stored procedure or function.

Harikrishnan
  • 9,688
  • 11
  • 84
  • 127