3

am trying to create an admin user from the CLI while running the commands I get the following error:-

# php bin/magento admin:user:create --admin-user=pramod --admin-password=pramod@123 --admin-email=pramod.mishra@netsmartz.net --admin-firstname=pramod --admin-lastname=mishra

In AdminAccount.php line 262:

No Administrators role was found, data fixture needs to be run

No Administrators role was found, data fixture needs to be run

How to fix it? Any idea thanks

Update:

I have a new error now while logging in to admin.

More permissions are needed to access this.

2

3 Answers 3

2

For creating a new administrator account for Magento 2 we use the Magento CLI. Hope this helpful for you.

  1. Login into your Magento 2 Server with SSH

    ssh your-username@$your-server-ip

  2. Navigate to the Magento 2 directory e.g.

/home/cloudpanel/htdocs/magento2.com/ 3) Execute the following command in order to create a new administrator with username "new-admin" and password "!admin123!"

php bin/magento admin:user:create --admin-user='new-admin' --admin-password='!admin123!' --admin-email='info@domain.com' --admin-firstname='Jon' --admin-lastname='Doe'

Once the new Magento 2 administrator account has been created, you will see the following success message:

Created Magento administrator user named new-admin

Parameter explanation
Name    Value
--admin-user    Magento administrator user name
--admin-password    Magento administrator user password
--admin-email   Magento administrator user's e-mail address
--admin-firstname   Magento administrator user's first name
--admin-lastname    Magento administrator user's last name

To see all available options you can execute the following command

php bin/magento admin:user:create --help

For The role

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');
0

For me the problem was that the Admin role in the table was set to "Administrator" instead of "Administrators".

So I changed it directly in the database and now it works.

0

The error is caused because your database isn't complete, I had the same issue by creating a DB dump via Magerun 2 using the param --strip=@development.

Your authorization_role and authorization_role database tables are probably empty.

How to fix

Create a authorized admin role and rule.

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');

And delete all your previous admin users in your local environment.

DELETE FROM admin_user;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.