So the first steps were to locate the exact name of the cache table in the database. Here’s how this is done.
- Log into the MySQL server with the command mysql -u USER -p (Where USER is the name of the database admin user).
- Enter the user password when prompted.
- Switch to the database in question with the command use DATABASE; (Where DATABASE is the name of the database containing the corrupted table).
- List the tables on the database with the command show tables;
- Search for the table. In my case the table was actually called cache.
- Exit out of the MySQL command prompt with the command quite.
- Check the table in question for errors with the following command myisamchk /var/lib/mysql/DATABASENAME/TABLE_NAME.myi (Where DATABASENAME is the name of the database you are working with and TABLE_NAME is the name of the table to be checked.)
- The above command should indicate there are errors on the table. If this is the case you will need to repair them. In my case the output actually pointed me to another table mod_layout_config, so I knew I actually had to re-run the check command (show above) on the file mod_layout_config.myi.
- When the myisamchk command report errors, it’s time to repair the table. But before you run this next command, make sure you back up that database! You do not want to run the risk of losing your entire database. To repair the table in question issue the command myisamchk –recover /var/lib/mysql/DATABASENAME/TABLE_NAME.myi (Where DATABASENAME is the name of the database you are working with and TABLE_NAME is the name of the table to be checked.)
- If this does not fully recover the table, you can re-run the command replacing –recover with –safe-recover which is slower and more thorough.
That should do it. You should now be able to restart your MySQL database server and your web site should be able to connect to its database.