Bug #2282 Descrepency using password function
Submitted: 5 Jan 2004 5:51 Modified: 5 Jan 2004 6:16
Reporter: Rakesh Singh Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.0 OS:Windows (Windows XP Pro)
Assigned to: CPU Architecture:Any

[5 Jan 2004 5:51] Rakesh Singh
Description:
Inserting or updating a column using the password function does not yield the same results as selecting with the password function.

How to repeat:
insert into user_tab values ('admin',password('123');
+--------+----------------------+
| userid | pass                 |
+--------+----------------------+
| admin  | *23AE809DDACAF96AF0F |
+--------+----------------------+

select * from user_tab where pass=password('123');
Empty set (0.00 sec)

select password('123');
+-------------------------------------------+
| password('123')                           |
+-------------------------------------------+
| *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+-------------------------------------------+
[5 Jan 2004 6:12] Rakesh Singh
Apologies, this appears not to be a bug.
The password function generates a varchar which is 40 characters in length.
If a column is smaller (ie. 20 as in the supplied example), the remaining 20 characters are truncated.
So columns which store data encryped with the password function need to have a length of 40 or more.
[5 Jan 2004 6:16] MySQL Verification Team
Not a bug as duly noted by the user himself.