Create Admin User in Magento 2 via Command Line

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:

  1. Open a command prompt or terminal.
  2. Navigate to the root directory of your Magento 2 installation.
  3. Run the following command to create the admin user:
    php bin/magento admin:user:create –admin-user=johndoe –admin-password=StrongPassword123 – –admin-firstname=john –admin-lastname=doe

    Replace johndoe,123456789  and <password> with the actual values.

    For example:

    php bin/magento admin:user:create –admin-user=johndoe –admin-password=!@sadfsdfsdsqwerfd – –admin-firstname=john –admin-lastname=doe

  4. After executing the command, you’ll be prompted to verify the information you provided. Type y and 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.