The MySQL OLD_PASSWORD function is used for generating a hashed password from a plaintext password string. The OLD_PASSWORD function uses hashing techniques to perform the generation of the hashed password. This function is carried out by the authentication system.
This function is used by the MySQL server to encrypt MySQL passwords for storage in the Password column of the user grant table. The value returned by the OLD_PASSWORD function is a hashed string, or NULL if the argument was NULL. The OLD_PASSWORD function accepts one parameter which is the string to be encrypted.
Syntax:
OLD_PASSWORD( plain_string )
Parameters Used:
- plain_string – It is used to specify the plain text string that is to be encrypted.
Return Value:
The OLD_PASSOWRD function in MySQL returns a hashed string.
Supported Versions of MySQL:
- MySQL 5.7
- MySQL 5.6
- MySQL 5.5
- MySQL 5.1
- MySQL 5.0
- MySQL 4.1
Example-1: Implementing OLD_PASSWORD function on a string.
SELECT
OLD_PASSWORD('xyz');
Output:
5re6hsuy7dsvgs25
Example-2: Implementing OLD_PASSWORD on a string with a combination of characters and integer values.
SELECT
OLD_PASSWORD('xyz123');
Output:
56fsrfshg312nsh34wf51
Example-3: Implementing OLD_PASSWORD function on a bigger string.
SELECT
OLD_PASSWORD('geeksforgeeks');
Output:
98dsygdy5syg43gs21
Example-4: Implementing OLD_PASSWORD function on a NULL string.
SELECT
OLD_PASSWORD('NULL');
Output:
NULL
Recommended Posts:
- MySQL | Common MySQL Queries
- MySQL | LEAD() and LAG() Function
- MySQL | BIN() Function
- MySQL | LAST_DAY() Function
- WEEKOFYEAR() Function in MySQL
- MOD() Function in MySQL
- MySQL | Creating stored function
- MySQL | Group_CONCAT() Function
- MySQL | DEFAULT() Function
- MySQL | AES_ENCRYPT ( ) Function
- MySQL | AES_DECRYPT ( ) Function
- MySQL | MD5 Function
- MySQL | COMPRESS( ) Function
- MySQL | PASSWORD Function
- MySQL | DES_DECRYPT ( ) Function
- MySQL | DES_ENCRYPT ( ) Function
- MySQL | DECODE( ) Function
- MySQL | ENCODE( ) Function
- MySQL | SHA1( ) Function
- MySQL | UNCOMPRESSED_LENGTH( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

