Twitter: too tired to do any more work. sleep.
Subscribe via RSS or email  #7,178


How To Quickie: Repair MySQL Tables

May 31, 2006 in ,

After a long, hard day of fetching and editing tables, MySQL can become overburdened and create overhead. This can be almost directly compared to how defragmentation occurs on a hard drive. For example, something needs to be replaced in one location but there is not enough space so part of it goes here and part goes there; discontinuous. Over time, overhead for very active tables in your database can reach high levels and the result will be something like what happened to me in March. You can ensure a healthy database by following this quick fix every once in a while.

1) Locate and login to your phpMyAdmin client.
2) Select the database and click on the name of the database (circled).

Repair MySQL Tables in phpMyAdmin

3) You should see all of the tables for your database.

Repair MySQL Tables in phpMyAdmin

4) Select the checkboxes for each table that has an overhead value.

Repair MySQL Tables in phpMyAdmin
This was only for example. Tables with an overhead value under a kilobyte aren’t really anything to worry about.

5) Go to the drop-down menu with selected on the bottom and select repair.
6) If everything works out, you will see the something like the image below.

Repair MySQL Tables in phpMyAdmin

7) Clicking on the database name again should show the screenshot below, with no overhead for any of the tables. That’s it!

Repair MySQL Tables in phpMyAdmin
No one has saved this post on del.icio.us. Why not bookmark it?



43 Comments

  1. Thanks, nice tip
    Ben

  2. cool!

    thanks for the quickies- so easy to understand, I could do it in my sleep! Now, if only I could get myself to “sleep surf”….

  3. Apparenltly, I had a lot of overhead. Now its all gone, thanks!

  4. Thanks for this tut, Paul! I’m usually wary about tinkering with stuff on my server because I’m still a relative n00b at it. This helps me out a lot.

  5. And why not optimize all the tables at the same same time? ;-)

    Check all —> optimize. Can/will quite often reduce the size of the database quite impressively (up to 10% or even more).

  6. Yeah what franky said. =D

  7. Thanx a lot for the tut.

    Just a few days ago, my database went kaput. :( I restored from a backup but that was a few days old — so I lost some comments.

  8. If my database is not open how i can fix the tables?. the phpmyadmin does not open.

    Thanks

  9. Good advice, thanks a lot. I’ve been creating, changing, deleting a lot of tables. Was beginning to wonder what this overhead deal I was seeing was about. Cleaned it all up nicely. Happiness abounds….

  10. tips, dont over optimize ur table too often, unless you want to increase the table lock.

  11. Thanks a lot !!!

  12. Hey thanks very very much. That would have taken me forever to figure out.

  13. Thanks! I can’t believe how easy that was… I was afraid I’d have to rebuild my whole DB… Ouch. And then all I needed to to was select Repair. The wonders of modern technology. At least now I know to check my DBs from time to time. :)

  14. Thanks for taking the trouble to stick it on the web. It worked perfectly.

  15. Glad to find this at the top of google for repair mysql table

    good lookin out

  16. Thanks a lot !!!

  17. Thanks for this post. phpMyAdmin is so convoluted that even though I’ve done this before I couldn’t remember how to do it a second time. I’m glad I found this.

  18. Thanks man. I was wondering what was happening to my mysql database. Saved my forum! :]

  19. Hi Paul. Last night I received this error:

    MySQL said:
    #1194 - Table ‘wp_options’ is marked as crashed and should be repaired

    I basically panic’ed and turned some more of my hair into grey hair

    But - I found this post and you literally saved me from doing something silly, like restoring a backup, or backstepping to the taped backups, etc … all I needed to do was repair the affected table like you suggested and everything worked out pretty good.

    Thanks for the tip. It’s timeless.

  20. Thanks for your help, Paul. I have been running around like a crazy man for the past two (2) days trying to resolve this error before my class presentation day. Finally, i came across your post and that helped me to resolved my problem. Kudos to you!!!!.

  21. This tip is very useful for MySQL admins…..

  22. I am fairly new at these thing..my site whent down and did not know what to to!!I found your post and everything is good now!!!!

    THANK YOU VERY VERY VERY MUCH!!!!!

  23. thanks, you just saved my blog!
    the wp_options table had crashed..
    the blog was showing the WordPress install page and erroring out if I ran the install.
    your fix sorted it out!!
    :)
    Matt Garrett

  24. Really useful article!! Thank you

  25. I found a couple quick mysqlcheck commands that optimize and repair MySQL databases on the following site: http://tuxrx.org/content/repairing-and-optimizing-mysql-databases

  26. Good article. My problem is related, I suspect, but different.

    All the data on my damaged table seems to have disappeared into the overhead area. When I browse the table, no records show, but autoindex shows 265. The material was being properly recorded until some unknown recent event. The overhead item shows 14,625 b in it.

    1) Is there any way to recover the data that is in the overhead section? Optimize will just erase it. Can “repair” be used to fix it?

    2) Any ideas as to what might have caused this problem? (All the other tables on the database seem to be working properly, and the data entry person doesn’t remember anything unusual happening.)

    Thanks for any help you can offer.

    Tim

  27. Thanks. My Search Index in Phpbb3 is working now !

  28. Thanks for great tips, i’m googling and found this information really useful. My website based on drupal and facing this problem.

  1. [...] To repair individual tables, there’s a nice rundown here: How To Quickie: Repair MySQL Tables [...]

  2. [...] orijinali How To Quickie: Repair MySQL Tables başlığında Toplamda 35 kez okunmuş. Şuan 3 kişi okuyor. En fazla 4 kişi aynı anda [...]

  3. [...] PhpMyAdmin ile MySQL veritabanınız altındaki tablolara göz attığınızda, “ek yük” sütunu altında kimi tabloların bir miktar veri içerdiğini görürsünüz. Uzun ve yorucu (tabloların sürekli yenilenmesi, içeriğinin çekilmesi, içeriğine ekleme-çıkarma-düzenlenme yapılması) bir gün boyunca MySQL yazılımına fazla yüklenildiği için, gün sonunda MySQL ek yükler yaratır. Gün sonlarında bu ek yükleri temizlemek ve tabloları onarmak, sağlıklı bir veritabanı için yapılması gereken en önemli olaydır. Bilmeyenler için şimdi MySQL tablolarının nasıl onarılacağını görelim # İlk olarak PhpMyAdmin ‘e erişmeniz gerekecektir. Bu nedenle cPanel, Plesk v.b. yönetim arayüzlerinden yönetim oturumunuzu açmanız ve PhpMyAdmin arayüzüne erişmeniz gerekir. # Tablolarını onarmak istediğiniz veritabanını seçin. Veritabanın içerisinde yer alan tüm tablolar listelenecektir. Bu listeden sadece “ek yük” sütunu dolu olanları seçin. Tablo listesinin hemen altındaki seçme kutusundan “Tabloyu onar” olanı seçin. # Herşey yolunda gittiyse resimdeki gibi tabloların onarıldığı konusunda mesaj alacaksınız. Tablo listesine geri döndüğünüzde toplam ek yükün sıfıra düştüğünü göreceksiniz. Hakan Demiray DmRy.net aldım orjinali burdaymış [...]

  4. [...] I was hit with an error after posting my Joost Invite post. I think there were error with the subscribe to post plugin. After disabling it, I had to fix it according to PaulStamatiou guide to Repair MySQL Table. [...]

  5. [...] Here is a How To for quickly repairing MySQl tables. I ran into this when I searched Google for “repair mysql table”. [...]

  6. [...] tengo espacio de sobra. Por suerte llegué a este post en Superaff que me llevó a este de PaulStamatiu en donde explica cómo solucionarlo usando phpMyAdmin. Era un problema de “residuos” en [...]

  7. [...] quickly followed the repair instruction found on Paul Stamatiou’s blog. Unfortunately, I could not start phpMyAdmin either. It gave me some error messages. [...]

  8. [...] Neste link encontram-se instruções de como proceder a esta operação usando o Phpmyadmin –> How To Quickie: Repair MySQL Tables [...]

  9. [...] I figured out how to fix my table in myphpadmin. This was a great tutorial. Ok, maybe not the coolest thing but it’s nice to know I can figure it out [...]

  10. [...] level4. Measure the performance of your website. One useful tool that I recommend is YSlow 5. Check, repair and optimize your MySQL database from [...]

  11. [...] Links: phpMyAdmin Homepage via PaulStamatiou “How To Quickie: Repair MySQL Tables” [...]

  12. [...] שיפור ביצועים נכנסים לממשק הניהול: phpmyadmin ומתחילים למחוק ידנית (אחד, אחד) רשומות לתוספות שאנחנו יודעים שכבר לא בשימוש. [...]

Post a comment, receive Stammy points.


Send a trackback.


  • If you plan on posting code, run it through Postable first.
Copyright © 2005 - 2008 PaulStamatiou.com  Privacy Policy - Terms of Service Can't spell my name? Use PSTAM.com. Go back up ↑.