Is performance really an issue here? It's likely to be marginal.
Doing it in MySQL makes the DB do more work, which is a good thing
Doing it in MySQL means the cleartext password gets passed further along (and the DB connection is often unencrypted).
This has nothing to do with SQL injection. You could fix the first version without moving the MD5 function. Also if there was a bug in PHP's MD5 function there's still a possibility of an injection attack.