Create Admin User in Magento 2 via Command Line
To create an admin user in Magento 2 via the command line, you can use the
bin/magento CLI tool. Follow the steps below to create an admin user:
- Open a command prompt or terminal.
- Navigate to the root directory of your Magento 2 installation.
- Run the following command to create the admin user:php bin/magento admin:user:create –admin-user=johndoe –admin-password=StrongPassword123 –firstname.lastname@example.org –admin-firstname=john –admin-lastname=doe
Replace johndoe,123456789 and <password> with the actual values.
php bin/magento admin:user:create –admin-user=johndoe –admin-password=!@sadfsdfsdsqwerfd –email@example.com –admin-firstname=john –admin-lastname=doe
- After executing the command, you’ll be prompted to verify the information you provided. Type
yand press Enter to confirm.The admin user john.doe was created successfully
The admin user is now created with the specified details.
Please note that the bin/magento CLI tool should be executed from the Magento root directory, and you should have the necessary permissions to create an admin user. Additionally, ensure that your Magento installation is in production mode, as the admin user creation command is not available in developer mode.