Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql Stored Proceedure: DEFINER=`root`@`%` is not working in localhost

I have searched on this problem a lot but could not find solution.

I am using stored procedure:

DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `GetImages`(
in search Varchar(80)
)
BEGIN
select  
image_path
from check_images
where checkNumber=search;

END

It is not working in localhost and getting following Error:

Error Number: 1449

The user specified as a definer ('root'@'%') does not exist

But if I replace % sign with "localhost" ('root'@'localhost') then everything works perfect. Also I am not allowed to alter the stored procedure. So please tell me the best solution that how can I overcome this problem.

I'll appreciate any help.

Thanks

like image 410
Maria Avatar asked Nov 27 '13 20:11

Maria


People also ask

How do I show Definer in MySQL?

To identify which DEFINER values exist in each table, use these queries: SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA. EVENTS; SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA. ROUTINES; SELECT DISTINCT DEFINER FROM INFORMATION_SCHEMA.

What is Definer in MySQL stored procedure?

The DEFINER clause specifies the MySQL account to be used when checking access privileges at routine execution time for routines that have the SQL SECURITY DEFINER characteristic.

What is stored procedure definer?

In this stored procedure, the definer is root@localhost that is the superuser which has all privileges. The SQL Security is set to the definer. It means that any user account which calls this stored procedure will execute with all privileges of the definer i.e., root@localhost user account.

What is definer and invoker in MySQL?

DEFINER is the account specified as the DEFINER when the stored routine or view was created (see the section above). INVOKER is the account invoking the routine or view. As an example, let's assume a routine, created by a superuser who's specified as the DEFINER , deletes all records from a table.


1 Answers

The message is quite clear that user does not exist.

In MySQL a user account consists of both the user name and the host definition component.

Either change the definer to 'root'@'localhost' or create a user for 'root'@'%'

like image 54
Mike Brant Avatar answered Oct 06 '22 01:10

Mike Brant