SQL Tutorial SQL Advanced SQL Database SQL References

MySQL OLD_PASSWORD() Function



The MySQL OLD_PASSWORD() function is used by the authentication system in MySQL to generate a hashed password from a plaintext password string, using older hashing techniques. To use newer hashing techniques, PASSWORD() function can be used which uses more powerful hashing as compared to older hashing techniques.

The OLD_PASSWORD() function returns the encrypted/hashed string, or NULL if the string is NULL.

The OLD_PASSWORD() function is used by the authentication system in MySQL to store passwords.

Syntax

OLD_PASSWORD(string)

Parameters

string Required. Specify the plaintext password string that is the source to create an encrypted/hashed password in MySQL, using older hashing techniques.

Return Value

Returns the encrypted/hashed password string.

Example:

The example below shows the usage of OLD_PASSWORD() function.

mysql> SELECT OLD_PASSWORD('xyz');
Result: '663c3a0b3da70572'

mysql> SELECT OLD_PASSWORD('password');
Result: '5d2e19393cc5ef67'

mysql> SELECT OLD_PASSWORD('alphacodingskills');
Result: '603a6f1a0d4653cc'

mysql> SELECT OLD_PASSWORD(123);
Result: '773359240eb9a1d9'

mysql> SELECT OLD_PASSWORD(NULL);
Result: NULL

❮ MySQL Functions