MySQL | PASSWORD Function

The MySQL PASSWORD function is used for the generation of a hashed password using a plain-text password string It uses hashing techniques to generate the hashed password. This function is carried out by the authentication system.

MySQL server uses the PASSWORD function to encrypt MySQL passwords for storage in the Password column of the user grant table. The value returned by the PASSWORD function is a hashed string, or NULL if the argument was NULL. The PASSWORD function accepts one parameter which is the string to be encrypted.

Syntax:

PASSWORD( string_to_encrypt )

Parameters Used:

  • string_to_encrypt – It is used to specify the plain text string that is to be encrypted.

Return Value:
The 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 PASSWORD function on a string.

SELECT 
PASSWORD('xyz'); 

Output:

6gd7gb67shy87865 

Example-2: Implementing PASSWORD function on a string with a combination of characters and integer values.

SELECT 
PASSWORD('xyz123'); 

Output:

54fg56gs32sgi3862 

Example-3: Implementing PASSWORD function on a bigger string.

SELECT 
PASSWORD('geeksforgeeks'); 

Output:

79sgs54uksr1fy76509 

Example-4: Implementing PASSWORD function on a NULL string.

SELECT 
PASSWORD('NULL'); 

Output:

NULL 
My Personal Notes arrow_drop_up


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 :


1


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