Posted in: Magento 2

Reset Magento 2 Admin User Role via MySQL

If you’re having an issue with logging into the Magento 2 admin due to permissions, sometimes you need to reset the user authorization. If you’re unable to access the admin, you’ll need to do this via MySQL command line, phpmyadmin, or something similar. Just adjust the two values I have marked as USERIDNUMBER and USERNAME in the following query and run it. You should be able to log back into the Magento 2 admin.

REPLACE INTO authorization_role
(`role_id`, `parent_id`, `tree_level`, `sort_order`, `role_type`, `user_id`, `user_type`, `role_name`)
VALUES
(2, 1, 2, 0, 'U', 'USERIDNUMBER', '2', 'USERNAME')

This works in Magento 2.2.x.

Have your say