Sam - September 14, 2016
If you’ve been having database issues and tried using the MySQL CLI client to look around your database, you may have found this error when trying to query some of your tables:
MySQL Table 'table_name' is marked as crashed and last (automatic?) repair failed
This can be caused by a number of reasons such as a hard reset on your server, zero disk space available or your MySQL process crashing for some reason.
How to fix this (the fast way)
ssh root@example.com
You can stop the MySQL daemon/service by running the command:
service mysql stop
Your MySQL directory is usually located in /var/lib/mysql
cd /var/lib/mysql/YOUR_DATABASE_NAME
Then simply run the myisamchk command by executing:
myisamchk -r table_name
Replacing table_name with your actual MySQL table name
Output:
root@example:/var/lib/mysql/database_name# myisamchk -r table_name
- recovering (with sort) MyISAM-table 'table_name'
Data records: 0
- Fixing index 1
Found block that points outside data file at 1694719836
Data records: 5965594
service mysql start
Your MySQL table should now be working again, at least in my case this fixed the problem.