Open In App

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:



Return Value:
The PASSWORD function in MySQL returns a hashed string.

Supported Versions of MySQL:

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 
Article Tags :
SQL