MySQL Password Function – OLD_PASSWORD() and PASSWORD()

The PASSWORD() function in MySQL can be used to generate a hash value for encrypted passwords, similar to using md5() in PHP. It is generally not recommended to use this function in an application as it is not particularly secure – it is intended for internal use.

If however your application uses the MySQL PASSWORD() function, you need to be aware that prior to MySQL 4.1 the function returns a 16 byte hash and in MySQL 4.1 and later the hash is 41 bytes. This means that a change of hosting or database upgrade will most likely result in your application breaking.

Fortunately, the function OLD_PASSWORD() is available in MySQL 4.1 and later to replicate the original PASSWORD() function. If you need a temporary solution, use OLD_PASSWORD() but make sure you update your code to be more secure as soon as you can.


Leave a Reply

Your email address will not be published.

More Posts

How to use PHP Type Declarations

PHP has developed into a more strictly typed language in recent years. Type Declarations help with that and are a fairly new addition to PHP,


If you have come to JavaScript from a background in Java or C, then you will like the variation on the for loop. It is

Context Object Manipulation

One of the key concepts of JavaScript is the keyword this, which signifies the JavaScript context object. If you write an inner function, you can access

Polymorphic Functions

It is possible to define multiple functions with the same name in JavaScript, and the last one of those that you define will be the