MySQL: OLD_PASSWORD Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL OLD_PASSWORD Function

In this guide, we will explain how to use the MySQL OLD_PASSWORD function with syntax and examples.

Description

The OLD_PASSWORD function is used by the authentication system to generate a hashed password from a plaintext password string, using hashing techniques prior to MySQL 4.1. To use newer hashing techniques, use the PASSWORD function.

Syntax

The syntax for the OLD_PASSWORD function is:

OLD_PASSWORD( string )

Parameters or Arguments

string

A plaintext password string that is the source to create an encrypted/hashed password in MySQL, using hashing techniques prior to MySQL 4.1.

Note

  • The OLD_PASSWORD function will return NULL, if the string is NULL.
  • The OLD_PASSWORD function was added in MySQL 4.1 when the password hashing techniques changed with the introduction of the PASSWORD function in MySQL 4.1.
  • The OLD_PASSWORD function is used by the authentication system in MySQL to store passwords.
  • Do not use th OLD_PASSWORD function in your own application, use the MD5 or SHA1 functions instead.
  • See also the ENCRYPT function.

Applies To

The OLD_PASSWORD function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1

Example

Let’s look at some LD_PASSWORD function examples and explore how to use the OLD_PASSWORD function.

For example:

mysql> SELECT OLD_PASSWORD('abc');
Result: '7cd2b5942be28759'

mysql> SELECT OLD_PASSWORD('password');
Result: '5d2e19393cc5ef67'

mysql> SELECT OLD_PASSWORD('adglob');
Result: '74c3b52b462a1a89'

mysql> SELECT OLD_PASSWORD(NULL);
Result: NULL

Next Topic : Click Here

This Post Has One Comment

Leave a Reply