MySQL | OLD_PASSWORD Function

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 


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.