How to create admin user using Command Line Interface | Magento 2

As you know a Magento Administrator can create a new user of any role from admin panel, but in some cases, one might need to create it from some other means rather than the conventional method (i.e. using Magento Admin Panel). E.g. if you forget admin login credentials, and you are unable to reset it by normal methods, then you will need some alternate way. This blog explains how you can add a new admin user using command line interface.

This is the command for adding new admin user:

php bin/magento admin:user:create --admin-user="username" --admin-password="password" --admin-email="[email protected]" --admin-firstname="First Name" --admin-lastname="Last Name"

You need to put proper information for username, password and email id and make sure neither username or email should be attached with existing admin users.

That’s all folks. You are all set to create new admin user using CLI.