[MySQL Error] The user specified as a definer does not exist
Background
When I execute a SQL script of the dump of a database structure and data, occurs an error “The user specified as a definer 'xxx'@'%'
does not exist”.
Error Info
SQL Error (1449):The user specified as a definer ('xxx'@'%') does not exist |
Solutions
This commonly occurs when exporting views/triggers/procedures from one database or server to another as the user that created that object no longer exists.
For example, the following is a trigger create statement:
CREATE |
Solution 1: Change the DEFINER
This is possibly easiest to do when initially importing your database objects, by removing any DEFINER
statements DEFINER=some_user
from the dump.
Changing the definer later is a more little tricky. You can search solutions for “How to change the definer for views/triggers/procedures”.
Solution 2: Create the missing user
If you’ve found following error while using MySQL database:
The user specified as a definer ('some_user'@'%') does not exist` |
Then you can solve it by using following :
CREATE USER 'some_user'@'%' IDENTIFIED BY 'complex-password'; |
Reasons
My exported trigger has a definer user that does not exist.
When you insert data into the table used in the trigger, MySQL will occur the error “The user specified as a definer xxx
does not exist”.
References
[1] MySQL error 1449: The user specified as a definer does not exist