Question
Create new admin user in magento 2 command
Answer
Below is the official Magento 2 CLI command to create a new Admin user. This is the standard, supported method and works on all Magento 2.x versions.
Magento 2 â Create Admin User via Command Line
Run this from your Magento root directory:
php bin/magento admin:user:create \
--admin-user="adminusername" \
--admin-password="StrongPassword@123" \
--admin-email="admin@example.com" \
--admin-firstname="Admin" \
--admin-lastname="User"
Example (realistic)
php bin/magento admin:user:create \
--admin-user="test_admin" \
--admin-password="test@2026!" \
--admin-email="test@example.com" \
--admin-firstname="test" \
--admin-lastname="family"
Password Requirements (Important)
Magento enforces strong passwords:
- Minimum 7 characters
- At least 1 uppercase
- At least 1 lowercase
- At least 1 number
- At least 1 special character
If the password is weak, the command will fail.
Verify Admin User Created
You can confirm via database (optional):
SELECT username, email FROM admin_user;
Common Errors & Fixes
1. Command not found
Ensure you are in Magento root and PHP CLI is available:
php -v
2. Permission issues
Run:
php bin/magento cache:flush
php bin/magento setup:upgrade
3. Locked out / forgot admin access
This CLI method is the recommended recovery approach.
If you want:
- Reset an existing admin password
- Enable/disable admin user
- Create admin via database (emergency only)
Tell me which one you need.