Error: 1449, “The user specified as a definer (

2019-07-18 23:36发布

问题:

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.

回答1:

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



标签: mysql sqlyog