1

Solved: See @RiggsFolly answer below for adequate work around.

Goal: I want to update user passwords using phpMyAdmin that have been stored using the password_hash() with PASSWORD_BCRYPT.

I am working on a web DB where the user passwords are set using php code such as:

$newPWHash = password_hash($newPW, PASSWORD_BCRYPT);

and then written into the database using:

$sql = "update employees set pw_hash = :newpwhash where employee_id = :id";

That part is fine, and I get how that is working. However, now I am trying to go back in an change user passwords for a number of accounts I created, and I would prefer to do it using phpMyAdmin's SQL window. I have tried:

UPDATE  `table` SET  `pw_hash` = PASSWORD('test') WHERE `email_address` =  '[email protected]'

However, this doesn't seem to be generating the same password. All the other passwords have the $2$y structure, and the ones generated by the above are not.

How to get this to work?

7
  • 1
    PASSWORD('test') !== password_hash('test', PASSWORD_BCRYPT) Commented Dec 11, 2016 at 10:18
  • Thats right its not the same. Write a User password change script. You will need one anyway Commented Dec 11, 2016 at 10:18
  • I have a user reset function that works, but it mails out the password to the user - since these are dummy accounts I basically just want to set a bunch of passwords manually - hence wanting to do it with PhPmyAdmin Commented Dec 11, 2016 at 10:37
  • 1
    Possible duplicate of How to use `bcrypt` algorithm within `encrypt` function in MySQL for verifying password? Commented Dec 11, 2016 at 10:42
  • 2
    My Workaround: Create a new acc using normal PHP method using a password you like. Then copy paste this HASHED password into which ever accounts you want to mess with using a simple UPDATE query. Commented Dec 11, 2016 at 10:51

1 Answer 1

1

Just to highlight that there is an answer for this now: My Workaround: Create a new acc using normal PHP method using a password you like. Then copy paste this HASHED password into which ever accounts you want to mess with using a simple UPDATE query. – RiggsFolly Dec 11 '16 at 10:51

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.