Admin role have no permissions, when I log in I just see only a extensions. How to reset permission in database MAGENTO 2 version?
2 Answers
[ Magento 2.x.x ]
Yes I also done this When I make First time in Module acl.xml and I was check it whether it works or not.
I try to create a Admin user one, two , three.... and no Admin user access, because I remove All Administrators's Role.
then I done Below thing to get All Admin user's Role ( Reset Role ).
Note:- use mysqldump to back up your databases before doing anything further
Step-1: Back up below Tables
Table 1 :- admin_user
Table 1 :- authorization_role
Table 1 :- 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
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);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');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 user not working create an new admin user in terminal click here
Now your Administrators Role are Reset to default.
I Hope This Helps You.
-
and next time you have to create another user role which have same as a admin role but not a exactly same to same role for next time this problem not create– MsquareCommented Sep 21, 2019 at 10:11
If you're finding this because like me you have accidentally removed your permissions to update your admin user account role's permissions and are now locked out of your account, use this query in the DB to reset the permissions for your role:
UPDATE authorization_rule SET permission = "allow" WHERE role_id = 1
You have to switch the role_id with your current role's ID of course.
authorization_role
table, see your role name and update value forparent_id
to be1
. hope this works