My website is running on Magento 2. I have migrated data from Magento 1.x to version 2.1 using UB data migration tool. Now I am planning to upgrade Magento 2.1.3. After Magento upgrade

I am unable to save new products. It shows error:

SQLSTATE[HY000]: General error: 1449 The user specified as a definer ('rb_magento2'@'localhost') does not exist, query was: INSERT INTO catalog_product_entity (entity_id, attribute_set_id, type_id, sku, has_options, required_options) VALUES (?, ?, ?, ?, ?, ?)

The user rb_magento2 is or live Magento database but I have created a copy of Magento on a new server with the different username.


2 Answers 2


I had the same problem and I got the solution doing this:

  1. Export database using the following command:

    mysqldump -h [database_host] --user=[database_username] --password=[password] --single-transaction main | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip > /path/to/database_name.sql.gz
  2. Import the database again.

The error is caused because the user rb_magento2 doesn't exist or doesn't have permissions.

Also you can try creating a user with name rb_magento2 but the first solution is the most recommended.

Check this doc: https://devdocs.magento.com/guides/v2.2/cloud/live/stage-prod-migrate.html#troubleshooting-the-database-migration


1 - You can fix that renaming the file app/etc/env.php to app/etc/env.php.bkp.

2 - Use the command cat app/etc/env.php.bkp to see the DB credentials.

3 - Run these commands below changing the data like DB host, user, password, base URL, admin user, password, etc..

php -f ./bin/magento setup:install --base-url=http://localhost/ \
    --db-host=db \
    --db-name=magento \
    --db-user=magento \
    --db-password=magento \
    --admin-firstname=Magento \
    --admin-lastname=Commerce \
    [email protected] \
    --admin-user=admin \
    --admin-password=admin123 \
    --language=en_US \
    --currency=USD \
    --timezone=America/Chicago \
    --use-rewrites=1 \

4 - Finalize running these commands:

alias mage="php -d memory_limit=-1 -f bin/magento"

mage maintenance:enable
rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/di/ var/tmp/ var/generation/ pub/static/frontend/ ;
mage setup:upgrade &&
mage setup:db-data:upgrade &&
mage dev:source-theme:deploy &&
mage cache:flush &&
mage indexer:reindex &
chmod -R 775 pub/static/ pub/media/ var/
mage setup:static-content:deploy
mage setup:di:compile
mage maintenance:disable
mage setup:db-schema:upgrade
mage setup:db-data:upgrade
mage setup:db:status


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.