First, manually delete all existing comments -- if your site's been heavily
spammed, the large number of comments will make logging in very slow.

delete from wp_comments;

Now log in to wordpress admin and go to Settings > Discussion and disable
comments and trackbacks by default.

All existing posts & pages still have comments enabled, though, so we need to
fix that manually:

update wp_posts set comment_status='closed';
update wp_posts set ping_status='closed';

Note: it's a good idea to look at these tables before updating them; future
versions of wordpress might use a different flag from 'closed' to indicate
commenting is disabled.