Shopping cart

Magento 2 How to Add Admin User via Command Line

In this tutorial, we will talk about How to Add Admin User via Command Line in Command Line Series. As you know, from Magento 2, they add many commands in bin/magento. This may difficult to get approach this, let me explain more detail about How to Add Admin User via Command Line.

How to Add Admin User via Command Line

Go to Magento admin root folder and 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

Let create a admin account with the following information:

  • User: mageplaza
  • Password: WeLoveMagento
  • Email: [email protected]
  • First Name: Mageplaza
  • Last Name: Family

So we the command line is:

php bin/magento admin:user:create --admin-user=mageplaza --admin-password=WeLoveMagento [email protected] --admin-firstname=Mageplaza --admin-lastname=Family

It shows an error: Your password must include both numeric and alphabetic characters. The password should be more complex.

  • Password: WeLoveMagento123
php bin/magento admin:user:create --admin-user=mageplaza --admin-password=WeLoveMagento123 [email protected] --admin-firstname=Mageplaza --admin-lastname=Family

And I created successfully a new admin account, it returned message:

Created Magento administrator user named mageplaza

Now to go to admin login page, and fill the above information

magento 2 login

and I’m in now, see this screenshot

magento 2 admin pannel





Meet Mageplaza at Meet Magento Asia

Enjoyed the tutorial? Spread it to your friends!

magento-2-module-development
command
line
cli
console

Comments for Magento 2 How to Add Admin User via Command Line

Please leave comments if you have any questions, feedbacks.

Module Development

We recommend:

You also may like these Magento 2 Extensions

One Step Checkout

$199
111 reviews

Layered Navigation

$99
59 reviews

Gift Card

$199
6 reviews

Reward Points

$99
4 reviews

Affiliate

$149
12 reviews

Shop By Brand

$99
16 reviews