Mysql Old_password Function

MySQL: OLD_PASSWORD Function

This tutorial explains how to use the MySQL OLD_PASSWORD function with syntax and examples.

Description

The MySQL 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 in MySQL 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 of MySQL:

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

Example

Let's look at some MySQL OLD_PASSWORD function examples and explore how to use the OLD_PASSWORD function in MySQL.

For example:

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

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

mysql> SELECT OLD_PASSWORD('AODBA');
Output: '6dfd6aed19e9c757'

mysql> SELECT OLD_PASSWORD(NULL);
Output: NULL