When this happened on my server a while back I copied the data from the old /var/lib/mysql to the new /var/lib/mysql and then checked that the databases weren't corrupt; in my case, they where fine, and completely up to date. Then I just moved over my flat files for the site.