Chris Bornhoft Chris Bornhoft - 7 months ago 94
MySQL Question

OLD_PASSWORD Function in 5.7.5+

I'm working with a legacy codebase here that currently uses

as a simple hashing function. This codebase now needs to connect to a database running the newest revision of MySQL 5.7.

The equivalent of
seems to be:

Is there a similar equivalent to


It appears there is no equivalent to OLD_PASSWORD() using MySQL functions except if the server allows globals to be set. By executing the query SET @@global.old_passwords = 1;, as a user with super permissions, the PASSWORD() function then hashes passwords using the OLD_PASSWORD() algorithm.

If, like in our case above, you do not have a super user (Google CloudSQL does not support them), then a replacement algorithm is needed. Below are replacements for different languages:

C | Perl | PHP | Python

Disclaimer: MySQL's password functions are a joke in modern day security and should not be used if at all possible. In addition, I'm not responsible for any head asploding after taking a look at the algorithms above!