This article will explain how to manually set a customer’s password in the database, which will probably be helpful at times if you are developing an M2 site locally.

The customer_entity table contains a field called password_hash and this is where you will set the password manually.  But, first, you will notice this field contains a hashed value.  Before we can set this field to our new password, we must first understand how to convert a password into a hash, which can be accomplished by performing the following steps:

1.) Determine what the password should be.  You can choose anything you like. I’m going to use “Password123”.

2.) Determine a salt that you would like to use.  It can be whatever you would like. Here is the salt I’m going to use for this example “q5rRDlqcxQCWtDysSN8XaGAuYwHnyzcg”.

3.) Add the password onto the end of the salt: “q5rRDlqcxQCWtDysSN8XaGAuYwHnyzcgPassword123”

4.) Perform a sha256 on the value mentioned in quotes in step #3. Navigate to this link as it will convert the above value to a sha256 for you. Doing this will produce the following value: “74a4649189eff4f87d04ff84247830de124f338b02e89f5e7536eb14ebb9505c”.

5.) Next take the value in quotes in step #4 and add the following onto the end of it in this order: a colon,  the salt, and a “:1”.  This will result in the value below.

6.) Now, if you want to set a customer’s password to “Password123”.  In the customer_entity table, change the password_hash to the value determined in step #5.  Now, the password of that customer is “Password123”!