Error: 1449, "The user specified as a definer ('root'@'localhost') does not exist"

Oreo picture Oreo · Jul 13, 2016 · Viewed 25.8k times · Source

I get the above error when I try to retrieve data or insert data via my app to my database. The proc code is as follows

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_createUser`(
    IN p_name VARCHAR(20),
    IN p_username VARCHAR(20),
    IN p_password VARCHAR(20)
)
BEGIN
    if ( select exists (select 1 from tbl_user where user_username = p_username) ) THEN

        select 'Username Exists !!';

    ELSE

        insert into tbl_user
        (
            user_name,
            user_username,
            user_password
        )
        values
        (
            p_name,
            p_username,
            p_password
        );

    END IF;
END $$
DELIMITER ;

However, when I run the following query in my sqlyog it returns a 1: SELECT EXISTS(SELECT 1 FROM mysql.user WHERE USER = 'root');

I am using XAMPP and Python to make my app. Thanks in advance.

Answer

Liv picture Liv · Nov 18, 2016
grant all on *.* to 'root'@'%' identified by 'password' with grant option; 

Check: MySQL user specified as definer does not exist and MySQL error 1449: The user specified as a definer does not exist