Skip to content
Related Articles

Related Articles

MySQL | OLD_PASSWORD Function
  • Last Updated : 17 Feb, 2021

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_PASSWORD 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
Recommended Articles
Page :