2

I am developing a Store in Magento 2. I created an Admin Account at the time of installation of Magento 2. Later I tried to create another User (Who can only add product in the store) from Admin Panel and a User Role (Which has only product entry access). In this time I assigned Admin User to that specific role (Product entry).

Then I install a Magento 2 in local host and replaced all the data of admin_user , authorization_role, authorization_rule table of database to regain access of Admin User. But when I tried to login using that Admin User I am getting a Message You need more permissions to access this. I attached a screenshot below. How can I get previous Admin User with previous Access?

enter image description here

6 Answers 6

4

The fastet option you have is to create a new admin and reset the previous user's permissions.

You can do it from command line.

Move to your Magento's root and type:

php bin/magento admin:user:create \
    --admin-user="mynewuser" \
    --admin-password="mynewpassword" \
    --admin-email="[email protected]" \
    --admin-firstname="MyName" \
    --admin-lastname="MyLastName" 

This will create a new admin user with username mynewuser and password mynewpassword.

When you are in just fix your old admin user.

2

If you want to preserve the existing user name "admin" setting the following columns in admin_user table solves the issue for me,

Columns:

Failure Number - 0 first_failure - NULL lock_expires - NULL

PHP MyAdmin:

Using PHP MyAdmin

1

[ Magento 2.x.x ]

Note:- use mysqldump to back up your databases before doing anything further

Step-1: Back up below Tables

    Table 1 :-  admin_user
    
    Table 2 :-  authorization_role
    
    Table 3 :-  authorization_rule
    

Step-2: truncate Above three Table using truncate command ( not using DELETE command )

truncate table [ Table Name ];

Step-3: insert new User in with All Roles , Run below three Command

  1. This insert data into admin_user table

         INSERT INTO `admin_user` (`user_id`, `firstname`, `lastname`, `email`, `username`, `password`, `created`, `modified`, `logdate`, `lognum`, `reload_acl_flag`, `is_active`, `extra`, `rp_token`, `rp_token_created_at`, `interface_locale`, `failures_num`, `first_failure`, `lock_expires`, `refresh_token`) VALUES (1, 'admin', 'admin', '[email protected]', 'admin', '45cf9053530ceb9fde49794d9e6d81fd2ce481b0136067986a5c9bc139a7d08f:FivE4hOQqPtW1xdE:2', '2019-07-23 10:48:31', '2019-09-09 13:20:42', '2019-09-09 13:20:42', 46, 0, 1, '{\"configState\":{\"contact_contact\":\"1\",\"web_default_layouts\":\"0\",\"web_default\":\"1\",\"web_secure\":\"1\",\"web_seo\":\"1\",\"web_unsecure\":\"1\",\"wishlist_wishlist_link\":\"1\",\"wishlist_email\":\"1\",\"wishlist_general\":\"1\",\"admin_emails\":\"0\",\"admin_startup\":\"0\",\"dev_front_end_development_workflow\":\"1\",\"dev_restrict\":\"0\",\"dev_debug\":\"1\",\"dev_template\":\"0\",\"sw_megamenu_general\":\"1\",\"newsletter_general\":\"1\",\"newsletter_subscription\":\"1\",\"dev_js\":\"0\",\"admin_security\":\"0\",\"admin_url\":\"0\",\"admin_dashboard\":\"0\",\"admin_captcha\":\"0\",\"sw_megamenu_custom_links\":\"1\",\"sw_megamenu_cat_labels\":\"1\",\"cms_wysiwyg\":\"1\",\"catalog_frontend\":\"1\",\"catalog_fields_masks\":\"0\",\"catalog_review\":\"1\",\"catalog_productalert\":\"1\",\"catalog_productalert_cron\":\"1\",\"catalog_placeholder\":\"1\",\"catalog_recently_products\":\"1\",\"catalog_product_video\":\"0\",\"catalog_price\":\"0\",\"catalog_layered_navigation\":\"1\",\"catalog_search\":\"0\",\"catalog_seo\":\"0\",\"catalog_navigation\":\"1\",\"catalog_downloadable\":\"1\",\"catalog_custom_options\":\"0\",\"layered_navigation_module\":\"1\",\"layered_navigation_general\":\"1\",\"carriers_flatrate\":\"1\",\"carriers_freeshipping\":\"1\",\"carriers_tablerate\":\"1\",\"carriers_temando\":\"1\",\"carriers_ups\":\"1\",\"carriers_usps\":\"1\",\"carriers_fedex\":\"1\",\"carriers_dhl\":\"1\",\"shipping_origin\":\"1\",\"shipping_shipping_policy\":\"1\",\"tax_vertex_settings\":\"1\",\"tax_classes\":\"1\",\"tax_calculation\":\"1\",\"tax_defaults\":\"1\",\"tax_display\":\"1\",\"tax_cart_display\":\"1\",\"tax_sales_display\":\"1\",\"tax_weee\":\"1\",\"tax_vertex_seller_info\":\"0\",\"tax_vertex_delivery_terms\":\"0\",\"tax_avaiable_shipping_product_codes\":\"0\",\"tax_vertex_logging\":\"0\",\"dev_grid\":\"0\",\"dev_static\":\"0\",\"dev_image\":\"0\",\"dev_css\":\"0\",\"dev_translate_inline\":\"0\",\"general_store_information\":\"1\",\"general_single_store_mode\":\"1\",\"general_locale\":\"1\",\"general_region\":\"1\",\"general_country\":\"1\",\"productinquiry_general_option\":\"1\",\"productinquiry_google_captcha\":\"1\",\"productinquiry_email_setting\":\"1\",\"trans_email_ident_general\":\"1\",\"product_attachment_general\":\"1\",\"product_attachment_display_configuration\":\"1\"}}', NULL, NULL, 'en_US', 0, NULL, NULL, NULL);
    
  2. This insert Data into authorization_role table

    INSERT INTO authorization_role (role_id, parent_id, tree_level, sort_order, role_type, user_id, user_type, role_name) VALUES (1, 0, 1, 1, 'G', 0, '2', 'Administrators'), (2, 1, 2, 0, 'U', 1, '2', 'admin');

  3. This insert Data into authorization_rule

    INSERT INTO authorization_rule (rule_id, role_id, resource_id, privileges, permission) VALUES (1, 1, 'Magento_Backend::all', NULL, 'allow');

Step-4: Run below Magento Command

    php bin/magento set:up;
    
    php bin/magento s:s:d -f ;
    
    php bin/magento c:f ;
    
    php bin/magento c:c ;
    

Step-5: Run your Admin login and try below username and password to login.

    username :- admin
    
    Password :- admin@123

if above username and password not working please create new admin user click here

Now your Administrators Role are Reset to default.

I Hope This Helps You.

1

In my case, the authorization_role and authorization_role tables were empty.

SELECT * FROM authorization_role;
Empty set (0.001 sec)

SELECT * FROM authorization_rule;
Empty set (0.001 sec)

Insert into authorization tables

INSERT INTO authorization_role (role_id, parent_id, tree_level, sort_order, role_type, user_id, user_type, role_name) VALUES (1, 0, 1, 1, 'G', 0, '2', 'Administrators');

INSERT INTO authorization_rule (rule_id, role_id, resource_id, privileges, permission) VALUES (1, 1, 'Magento_Backend::all', null, 'allow');

Delete your existing admin user

DELETE FROM admin_user WHERE user_id = YOUR_USER_ID;

Create admin user again

bin/magento admin:user:create

Reference: Magento 2: No Administrators role was found

0

I had the same issue. It was because the users were not assigned any roles. So I created roles and assigned it to the users.

0

This problem arises when there is no association between a user account and the User ROLE, and when an account has been marked as inactive.

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.