MySQL Tutorial MySQL Advanced MySQL Database Account Management MySQL References

MySQL PASSWORD() Function



The MySQL PASSWORD() function is used by the authentication system in MySQL to generate a hashed password from a plaintext password string. It uses more powerful hashing as compared to older hashing techniques. To use older hashing techniques, OLD_PASSWORD() function can be used.

The PASSWORD() function returns the encrypted/hashed string, or NULL if the string is NULL.

The PASSWORD() function performs one-way encryption. This function is used by the authentication system in MySQL to store passwords.

Syntax

PASSWORD(string)

Parameters

string Required. Specify the plaintext password string that is the source to create an encrypted/hashed password in MySQL.

Return Value

Returns the encrypted/hashed password string.

Example:

The example below shows the usage of PASSWORD() function.

mysql> SELECT PASSWORD('xyz');
Result: '*39C549BDECFBA8AFC3CE6B948C9359A0ECE08DE2'

mysql> SELECT PASSWORD('password');
Result: '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'

mysql> SELECT PASSWORD('alphacodingskills');
Result: '*3CAF4FC498E7B7D0F274A6B22CC7A8149F3703E5'

mysql> SELECT PASSWORD(123);
Result: '*23AE809DDACAF96AF0FD78ED04B6A265E05AA257'

mysql> SELECT PASSWORD(NULL);
Result: NULL

❮ MySQL Functions

5