Solved: How to reset Magento 2 admin passwords using command line?

desctop-screenshot

You must have SSH access to your server in order to use this method. If you do not have SSH access, contact your web host to get one.

  1. Log in to your server with SSH. You can either use Putty or OS Terminal to connect.

    1. Run ssh your-username@hostname/IP
    2. Enter your password when prompted
  2. Navigate to your Magento installation, but replace the bracketed placeholders accordingly:

    cd /[home]/[demo]/[demosite.com]/[html]/

  1. Retrieve the admin user’s information from the database using the below command, but make the following adjustments:

    1. Replace [db_user] with your database user.

    2. Replace [db_name] with your database name.

    3. Within username=”[admin]'”, replace [admin] with the username requiring the reset. You will be prompted to for the database password before continuing.

      echo “select email,firstname,lastname from admin_user where username='[admin]'” | mysql -u [db_user] [db_name] -p

  1. To reset the password of a user, execute the following, but replace the bracketed placeholders between the quotation marks with the current user’s information:

    php bin/magento  admin:user:create –admin-user=”admin” –admin-password=”newpassword” –admin-email=”test@example.com”  –admin-firstname=”Test” –admin-lastname=”Test”

  2. hit enter and the password will be updated.

 

Leave a Reply

Your email address will not be published. Required fields are marked *