#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation
Asked Answered
G

6

46

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 
Gomar answered 9/7, 2015 at 11:8 Comment(0)
D
86

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

Denison answered 9/7, 2015 at 11:13 Comment(3)
I dump my database to sql file, I don't remember to create any function like this... Searching on dump file, I found on last line this commands, I remove and works, thanks.Wollis
Thanks, in my case I fixed it by renaming root@localhost to serverusername@localhost`Hackberry
Just replace root with database login nameChungchungking
D
44

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

Drawback answered 1/7, 2018 at 8:41 Comment(2)
It worked, that's a perfect answer. And GoDaddy told me that I should purchase a dedicated server for this, but you saved my day.Febrifacient
Otherwise, change the username to already all permission granted username.Hackberry
B
24

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

Bigoted answered 29/9, 2016 at 6:6 Comment(1)
yep it was control_panel_user@localhost for meEgon
R
8

remove DEFINER=root@localhost from all calls including procedures

Refugia answered 2/4, 2020 at 17:46 Comment(0)
W
0

Change

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

By

FUNCTION  `fnc_calcWalkedDistance` (
Westernism answered 30/12, 2020 at 20:6 Comment(0)
F
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.

Fiske answered 5/9, 2022 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.