Bookmark

How to Create an Admin User in Magento 2 Using Command Line Tools

How to Create an Admin User in Magento 2 Using Command Line Tools

Creating an admin user via the command line in Magento 2 is an effective way to manage your admin accounts. Although creating admin users manually from the backend is a common approach, using the command line offers additional flexibility and efficiency, especially for automated setups or when the backend is inaccessible.

  1. Open Your Command Line Interface

    Start by accessing the command line interface on your server or local environment. Change directory to the root of your Magento 2 installation:

    cd /path/to/your/magento2/root
  2. Run the Command to Create an Admin User

    Magento 2 provides a built-in command to create admin users. Use the following syntax:

    php bin/magento admin:user:create --admin-user="adminusername" --admin-password="adminpassword" --admin-email="admin@example.com" --admin-firstname="AdminFirstName" --admin-lastname="AdminLastName"

    Example:

    php bin/magento admin:user:create --admin-user="admin123" --admin-password="SecureP@ss2024" --admin-email="admin123@example.com" --admin-firstname="Admin" --admin-lastname="User"

    Parameters Explained:

    • --admin-user: Sets the username for the admin account.
    • --admin-password: Defines the password (must adhere to Magento’s complexity requirements).
    • --admin-email: Specifies the email address for the admin user.
    • --admin-firstname: Sets the first name of the admin user.
    • --admin-lastname: Defines the last name of the admin user.
  3. Check the Results

    After executing the command, a success message should confirm that the admin user was created.

Post a Comment

Post a Comment