HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

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

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
theuserexistrootdoesnotdefinerspecified

Problem

I have a trigger defined as follow:

USE `veeva_bi`;
DELIMITER $
DROP TRIGGER IF EXISTS veeva_bi.account_ai$
USE `veeva_bi`$
CREATE DEFINER = CURRENT_USER TRIGGER `veeva_bi`.`account_ai` AFTER INSERT ON `account` FOR EACH ROW
BEGIN
    // do trigger stuff here
END$
DELIMITER ;


When I run that query I got the trigger created as root@localhost:

CREATE DEFINER=`root`@`localhost` TRIGGER `veeva_bi`.`account_ai` AFTER INSERT ON `account` FOR EACH ROW
BEGIN
    // do trigger stuff here
END


But any time I try to run a PHP script, that connects to MariaDB as root user I got this error:

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1449 The user specified as a definer ('root'@'%') does not exist' in /var/www/html/veeva_replicator/DB.php:158


Why is that? I have others triggers created on the same way and them did works but this one doesn't, any advice or help regarding this?

Solution

I met this problem when update a row in mysql.

I connect mysql use a diffrent user and password rather than root.

When I type "show triggers" in mysql, I found the triger use "root@%", this will cause this exception.

Context

StackExchange Database Administrators Q#107536, answer score: 4

Revisions (0)

No revisions yet.