How to fix a corrupted WordPress comments table

I logged into my WordPress admin panel and saw these ominous warnings:

'./your_wordpress_database/wp_comments' is marked as crashed and should be repaired.

Uh oh. That doesn’t seem good. I went to one of my blog posts and it said the same thing. OK no need to panic. I run my own WordPress on a virtual private server and also administer my own MySQL databases.

The solution is remarkably simple:

  1. Run the mysql client. mysql -u your_wordpress_user -p
  2. Switch to your WordPress database. use your_wordpress_database
  3. Issue the command repair table wp_comments