0

I'm getting this error when I try to add images to a product.

SQLSTATE[42000]: Syntax error or access violation: 1142 TRIGGER command denied to user 'OLDUSER'@'localhost' for table 'catalog_product_entity_media_gallery', query was: INSERT INTO `catalog_product_entity_media_gallery` (`attribute_id`, `value`, `media_type`) VALUES (?, ?, ?)

I've moved the site to a different account with a different DB user, I've updated the env.php with the new details and everything appears to work fine on the frontend and in the admin area except this.

I've cleared the whole var folder, re-compiled, re-deployed, etc. So where is it getting the old DB details from?

I've tried grep oldDBuser and the only thing that shows is the exception log.

2
  • Have everyone resolve this issue? I've the same error.
    – Mastafis
    Jul 2, 2019 at 15:59
  • have you ever resolve the issue? Mar 23, 2021 at 21:21

4 Answers 4

2

Just to clarify other answer. The issue is not magento. The issue is mysql.

The mysql trigger needs to be removed /edited.

As far as I'm aware magento doesn't ship with (many) triggers https://stackoverflow.com/a/50712557/10121426 which means this is an extension or modification.

How did you migrate? I think possibly your migration process has created a trigger with old user details.

You could look into identifying the trigger show triggers \G and deleting the one that's causing you problems but it's likely that something will break as the result of doing this. It will be safer to edit. But I can't say for certain what the updated trigger should be.

3

In cPanel or your hosting, select all privileges including Trigger privilege for that database user and then check again. So basically you need to grant Trigger permission to that database user.

1
  • The correct user has those permissions. I'd rather fix this in Magento than giving a user in an old account access to a DB in another account. Mar 22, 2018 at 13:12
3

step 1: backup your database

step 2: explode your database to a file as .sql

step 3: find "OLDUSER'@'localhost" on your file and replace with current user in mysql of your project.

step 4 save and import data again.

Hope it will help you

1

To add to @Dominic Pixie answer above. You can go to PhpMyAdmin > 'Triggers' tab. There you'll find a list of triggers and you can click on 'edit' and then update the 'definer' field to the correct db username.

As ever take a backup before you change any database values.

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.