Check Unix Password Hash in MySQL
Here's how you use MySQL to verify a password when using UNIX password hashes in a MySQL database.
mysql> select encrypt('helloworld',substr('$1$ANfA9ktr$g31j3VCTzi8vYdSTiHY29/', 1, 12) );
+-----------------------------------------------------------------------------+
| encrypt( 'helloworld',substr('$1$ANfA9ktr$g31j3VCTzi8vYdSTiHY29/', 1,12) ) |
+-----------------------------------------------------------------------------+
| $1$ANfA9ktr$g31j3VCTzi8vYdSTiHY29/ |
+-----------------------------------------------------------------------------+
1 row in set (0.00 sec)
Of course you'd replace the actual hash in the select command with the column name that has the password stored.
select * from user where uid='scott' and password = encrypt( 'helloworld',substr(password, 1, 12) )