Tried creating admin user from command line with the following command:
bin/magento admin:user:create
After completion of the command run, I got the following error in the terminal:
No Administrators role was found, data fixture needs to be run
When I try to login to the admin via browser, I get this error:
More permissions are needed to access this.
Cause
authorization_role
and authorization_role
database tables were empty.
SELECT * FROM authorization_role;
Empty set (0.001 sec)
SELECT * FROM authorization_rule;
Empty set (0.001 sec)
Solution
Insert data into authorization_role
and authorization_role
database 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');
Query OK, 1 row affected (0.004 sec)
INSERT INTO authorization_rule (rule_id, role_id, resource_id, privileges, permission) VALUES (1, 1, 'Magento_Backend::all', null, 'allow');
Query OK, 1 row affected (0.034 sec)
Check the tables again
SELECT * FROM authorization_role;
+---------+-----------+------------+------------+-----------+---------+-----------+----------------+------------+--------------+------------------+
| role_id | parent_id | tree_level | sort_order | role_type | user_id | user_type | role_name | gws_is_all | gws_websites | gws_store_groups |
+---------+-----------+------------+------------+-----------+---------+-----------+----------------+------------+--------------+------------------+
| 1 | 0 | 1 | 1 | G | 0 | 2 | Administrators | 1 | NULL | NULL |
+---------+-----------+------------+------------+-----------+---------+-----------+----------------+------------+--------------+------------------+
1 row in set (0.000 sec)
SELECT * FROM authorization_rule;
+---------+---------+----------------------+------------+------------+
| rule_id | role_id | resource_id | privileges | permission |
+---------+---------+----------------------+------------+------------+
| 1 | 1 | Magento_Backend::all | NULL | allow |
+---------+---------+----------------------+------------+------------+
1 row in set (0.000 sec)
Delete recently created admin user
If you had created an admin user, then delete that user from the admin_user
table and create the user again.
SELECT * FROM admin_user WHERE email = 'your.user@example.com';
DELETE FROM admin_user WHERE user_id = YOUR_USER_ID;
After that, you should be able to log in to the Magento admin panel.
Hope this helps. Thanks.