Magento 2 Create Admin User Through Command
This tutorial will cover the process of adding an admin user through the command line. Magento 2 includes a variety of commands in the bin/magento directory. However, I will provide more detailed information on how to add an admin user through the command line.
How to Create Admin User Through Command Line in Magento 2?
Go to Magento 2 root Directory and run this command to show usage:
php bin/magento admin:user:create --help
Output:
Usage: admin:user:create [options] Options: --admin-user=ADMIN-USER (Required) Admin user --admin-password=ADMIN-PASSWORD (Required) Admin password --admin-email=ADMIN-EMAIL (Required) Admin email --admin-firstname=ADMIN-FIRSTNAME (Required) Admin first name --admin-lastname=ADMIN-LASTNAME (Required) Admin last name --magento-init-params=MAGENTO-INIT-PARAMS Add to any command to customize Magento initialization parameters For example: "MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/example.com&MAGE_DIRS[cache][path]=/var/tmp/cache" -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: Creates an administrator
Now we will create an admin user through the command line. In root folder run the following command:
php bin/magento admin:user:create --admin-user=GD User --admin-password=pass123 --admin-email=admin@abc.com --admin-firstname=GD --admin-lastname=Blogger
In the above command,
- User: GD User
- Password: pass123
- Email: admin@abc.com
- First Name: GD
- Last Name: Blogger
You can also run this command in the root folder to create a new admin user.
php bin/magento admin:user:create
After running this command, the admin user was created successfully. Now go to the admin page and login using these user details. After login, you can see your admin dashboard.
I hope this guide will assist you in addressing the issue. Please do not hesitate to contact us through the comments section if you have any further questions.
If you want to get more knowledge, click on Magento 2.