OK, first, use at your own risk! (ETA ...and if you decide you don't want to risk it, I understand). You should backup your database first, or at least the customavatar table.
Upload the attached file to your forum directory, then point your browser at it (i.e.
www.mydomain.com/forum/fixavatars.php). You must be logged in as an admin. I'm not sure how long it will take, but it won't look like it's doing anything until it's done (it'll look like it's taking a long time to load the page), so be patient.
If it works, when you run it a second time it should immediately tell you that it removed 0 rows.