For creating a new administrator account for Magento 2 we use the Magento CLI.
Hope this helpful for you.
Login into your Magento 2 Server with SSH
ssh your-username@$your-server-ip
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='[email protected]' --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');