paul bennett

the password() function – mysql 4 vs. mysql 5

Posted on: March 17, 2008

We’re planning on upgrading from an archaic mysql engine (3.58) to the latest, shiny release version (5.1), so I’ve undertaking a code review of some of our administration applications to see what this unearthed.

Turns out the password hashing for the MySQL native PASSWORD() function changed in version 4.1, so our login system won’t work in 5.1. Great.

Turns out we’ll be able to skirt around this by making sdure this line is in the new my.cnf file:

old-passwords = 1

It’s great this was thought of, as PASSWORD() is a one-way, irreversible function, so authentication will fail for any old application using it when it is run on mysql >= 4.1.

thanks to []


Need to improve your MySQL skills? I recommend:
High Performance MySQL: Optimization, Backups, Replication, and More


4 Responses to "the password() function – mysql 4 vs. mysql 5"

Hi, I’m having the same problem on several websites I have programmed. The hosting company is migrating all servers gradually to MySQL 5 so all queries using the “PASSWORD()” function will cease to work. I found a forum entry here:
which provides several solutions. I, for one, am replacing the “PASSWORD()” function with “OLD_PASSWORD()” in my queries until I have the occasion to “force” all users to update their password.


Thanks Lucas. Fortunately our user table was small, so I was able to simply recreate the passwords using the updated hashing in MySQL5.

I wasn’t even aware of the old_password() function!

Thank you Paul.
A week ago I got this page and I practiced everything here.
It’s so helpfull. Good luck brother! 🙂

[…] may I can do. A few minutes later, O thanks God, I get it. Not from the official of MySQL, but from this site. By default, function password() is not supported anymore by the updated MySQL server. But, if we […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: