I want to reset one of my customer's password through database. What is the query for this in magento 2.
2 Answers
Try to execute this query in your database :
UPDATE `customer_entity` SET `password_hash` = SHA2('admin123', 256) WHERE `entity_id` = 1;
or
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
<?php
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?– NafsssMar 11, 2020 at 6:42
-
-
Mail is sent to customer's email id. I dont want that. I want to reset password on my own– NafsssMar 11, 2020 at 6:48
-
Okay. Then, you can't able to update from admin panel. You need to execute query in DB. Mar 11, 2020 at 6:49
-
ok, Is it possible to change the email to mine, then after resetting the password, again change the email to customers?– NafsssMar 11, 2020 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;'