I want to reset one of my customer's password through database. What is the query for this in magento 2.

  • @Nafisha Did you able to update? – Rohan Hapani Mar 11 '20 at 10:09

Try to execute this query in your database :

UPDATE `customer_entity` SET `password_hash` = SHA2('admin123', 256) WHERE `entity_id` = 1;


UPDATE `customer_entity` SET `password_hash` = CONCAT(SHA2('xxxxxxxadmin123', 256), ':xxxxxxx:1') WHERE `entity_id` = 1;
  • replace value of password instead of admin123
  • replace value of xxxxxxx with crypt key.

You can get crypt key from app/etc/env.php file

return array (
  'crypt' => 
  array (
    'key' => 'c51288337454ecab8280de9989b7624d',

From admin panel,

You can click on "Reset Password" in customer edit form. Mail will be sent on appropriate email ID. Then, you can reset password.

Note : Take backup of your db before execute.

  • Thanx. Is there any way for admin to change customer's password from admin panel? – Nafsss Mar 11 '20 at 6:42
  • I update sql query and answer also. Please check it. – Rohan Hapani Mar 11 '20 at 6:47
  • Mail is sent to customer's email id. I dont want that. I want to reset password on my own – Nafsss Mar 11 '20 at 6:48
  • Okay. Then, you can't able to update from admin panel. You need to execute query in DB. – Rohan Hapani Mar 11 '20 at 6:49
  • ok, Is it possible to change the email to mine, then after resetting the password, again change the email to customers? – Nafsss Mar 11 '20 at 6:51

This SQL works just fine to update the customer password.

Just change YOURPASSWORD below (keep the xxx:es)

'UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('xxxxxxxxYOURPASSWORD', 256), ':xxxxxxxx:1')
WHERE `entity_id` = 1;'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.