Advertisement
database Is a common error in MySQL — especially with MyISAM tables. It usually happens when the server is shut down improperly, the disk becomes full, or a query is interrupted midway. This tutorial explains why this error appears, how to repair crashed tables safely, and how to prevent this problem from happening again, written in a simple, friendly tone for absolute beginners.

Fixing “MySQL Table is Marked as Crashed and Should Be Repaired” (Beginner-Friendly Guide)

5 Min Read Verified Content

Fixing “MySQL Table is Marked as Crashed” — Explained for Total Beginners

If you’ve ever opened your MySQL or phpMyAdmin and suddenly saw:

#145 - Table './database/table_name' is marked as crashed and should be repaired

…your heart probably dropped a little.

Don’t panic.
Don’t reinstall MySQL.
And please don’t delete your table (some beginners actually do this!).

This is one of the most common MySQL issues, and in most cases, it’s 100% fixable.

Let’s walk through this slowly and clearly, like a senior teaching a complete beginner.




1. What Does “Table is Marked as Crashed” Actually Mean?


This message does NOT mean your data is gone.

It simply means:

MySQL was interrupted while writing to the table, so the table's internal structure is inconsistent.

Think of it like writing a sentence in a notebook and someone suddenly grabs the book mid-sentence — the sentence becomes incomplete.

That’s all.




2. Why Does This Error Happen? (Most Common Causes)


Here are the top causes, explained simply:


🔥 Cause #1: Server crashed or rebooted suddenly

If MySQL was writing data during a shutdown, the table gets corrupted.

🔥 Cause #2: Disk is full

When MySQL can’t finish writing data → corrupted index files.

🔥 Cause #3: Interrupted queries

Long write operations killed halfway.

🔥 Cause #4: MyISAM storage engine

MyISAM is more fragile compared to InnoDB.

🔥 Cause #5: Power outage

Classic reason why tables break.




3. How to Check Which Table is Crashed


If you’re using Linux:

mysqlcheck --all-databases

Or a specific database:

mysqlcheck your_database_name -u root -p

MySQL will list crashed tables.




4. How to Repair a Crashed Table (Step-by-Step)


Now let’s fix it.



Method 1: Using REPAIR TABLE (Easy for Beginners)

In MySQL or phpMyAdmin:

REPAIR TABLE table_name;

If MySQL says:

OK

Then you're done.




Method 2: Use mysqlcheck (Server-side Repair)


This is safer and works even if MySQL is stressed.

mysqlcheck -r your_database table_name -u root -p

The -r option means repair.




Method 3: Manual File-Level Repair (Advanced but useful)


Use only if REPAIR TABLE fails.

  1. Stop MySQL:

systemctl stop mysql
  1. Go to your database folder:

cd /var/lib/mysql/your_database/
  1. Backup the corrupted files:

cp table_name.MYD table_name.MYD.bak cp table_name.MYI table_name.MYI.bak
  1. Run myisamchk:

myisamchk -r table_name.MYI
  1. Start MySQL:

systemctl start mysql

This usually fixes even stubborn corruption.




5. If the Table Still Won’t Repair


Sometimes the index is too damaged.

Try a “force repair”:

myisamchk --force --recover table_name.MYI

Or:

REPAIR TABLE table_name USE_FRM;

This rebuilds the table using the .frm file.

⚠️ Warning: This may cause small data loss in extreme cases — but it still saves most rows.




6. How to Prevent Tables from Crashing Again


Here’s the long-term solution.

✔ Switch from MyISAM → InnoDB

MyISAM is old, slow, and breaks easily.

To convert:

ALTER TABLE table_name ENGINE=InnoDB;

✔ Avoid forced shutdowns

Always stop MySQL properly:

systemctl stop mysql

✔ Use a UPS if your environment is unstable

Power loss = table corruption.

✔ Monitor disk space

MySQL crashes when disk hits 0%.

Check:

df -h

✔ Enable automatic checks

Add a weekly cron:

mysqlcheck --all-databases | mail -s "MySQL Check Report" your@email


7. Real Example (Before & After)


❌ Before

  • User lost access to important tables

  • phpMyAdmin showing “table is marked as crashed”

  • Website unable to insert data

  • Panic everywhere

✔ After Repair

  • Ran REPAIR TABLE

  • Converted engine to InnoDB

  • Reduced risk of future corruption

Everything runs smoothly again.




Conclusion


A crashed MySQL table is not a disaster.
It’s a simple issue with simple fixes:

  • Identify the crashed table

  • Repair it safely

  • Convert to InnoDB

  • Prevent future corruption

Even a complete beginner can fix this in minutes.

Advertisement
Back to Database