How to Repair Tables Marked Bad or Corrupt in MySQL

For more than a year we used the Counterizer plugin for WordPress and thus keep statistics of the blog and its readers, this plugin we deactivated a few days ago since (among other things) it saved more than 600MBs of data in the database.

It happens that (before deactivating the plugin and cleaning the DB) I tried to dump the database, that is, export it to .SQL and thus download it and in the hosting terminal I got the following error:

mysqldump: Got error: 144: Table './dl_database/Counterize_Referers' is marked as crashed and last (automatic?) repair failed when using LOCK TABLES

Therefore, the dump was not carried out and well... the mere idea of ​​thinking that the DB of DesdeLinux I had a problem, it made my hair stand on end :)

Doing a little research on the web I was able to learn how to solve this problem, apparently it is NOT that the database has problems exactly, simply that a table is marked as 'with problems', fortunately this is very simple to fix.

First let's access the MySQL server:

mysql -u root -p

We press [Enter] and it will ask for the MySQL root password, we put it and press [Enter] again.

This command is in case the MySQL server is installed on the same computer, if you want to connect remotely to another MySQL server you must add the following to the line: -h IP-OF-SERVER

Once inside MySQL we will tell you which database to use, for example the problem according to the error above is in the table Counterize_Referers from the database  dl_database, so that:

use database dl_database;

And now to repair the table base:

repair table Counterize_Referers;

Note that at the end of these lines there is a semicolon —– »  ;

Once the previous command has been executed, everything must have returned to normal, at least in my case it has been like that on more than one occasion 😉

Then it only remains to rerun the instruction to dump the database and voila, nothing more.

Anyway, I do this more than anything else as a memorandum for me, because the same thing has happened to me twice and I don't want to forget the instructions to save the day 😀

Greetings and I hope it is helpful to someone else.


19 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Leo said

    Very good, you always have to have this type of item on hand for whatever reason.

    1.    KZKG ^ Gaara said

      Thank you
      Yes… at the moment when the problem occurs, it is good to have the solution at hand, or at least to know where to find it without delay.

  2.   eliotime3000 said

    Good KZKGGaara. There are things that the PHPMyAdmin cannot do that the console can.

    1.    KZKG ^ Gaara said

      Thank you

  3.   Santiago said

    Excellent, saved me more than once.

    But I wonder, wouldn't it be mysql -u root -p instead of root -u root -p? I do not mean to offend.

    Thank you!!

  4.   Santiago said

    Excellent, saved me more than once.
    But I wonder, wouldn't it be mysql -u root -p instead of root -u root -p? I ask without the intention of offending.
    Thank you

    1.    KZKG ^ Gaara said

      LOL!!!! Completely true, my mistake LOL!
      I was writing and thinking a step ahead, from there to write root instead of mysql ... Thanks for the warning 🙂

      1.    Santiago said

        You're welcome! Sorry for the double post; I tried to send it repeatedly and it told me that it already existed (I reloaded the page and didn't see anything).
        Greetings.

  5.   Leper_Ivan said

    This comes out of my hair now that I'm getting into the DB issue.

  6.   Alexander said

    Hello good,

    One question, how often do you dump DB? is to know how long it takes to get up to 600MB of data

    Greetings,

    1.    KZKG ^ Gaara said

      Ehm… I didn't understand you very well now 🙂
      Before we did a cleanup in the DB of DesdeLinux This (that is, the .sql of the DB) weighed more than 700MB, because we kept all the statistics in the DB. That is, since almost the beginning of the blog.

      Now we are using Google A. so we delete the statistics tables from the DB, and now the .sql does not reach 80MB

      Does this answer your question?

  7.   Alexander said

    Hello good,

    Without troll, how often do you dump DB?

    1.    KZKG ^ Gaara said

      Several times a month 🙂
      I always try to have the latest version of DesdeLinux

  8.   you like buy it !! said

    It seems ok to me, now it is not possible to do a general revision of the corrupted tables?

  9.   Victoria said

    Thank you very much friend, your contribution helped me a lot.
    regards

  10.   Juan Mollega said

    Thank you very much dear, thanks for the tips, they helped me !!
    Greetings from Trujillo-Venezuela.

  11.   Hernan Barra said

    estimated
    As I know if the process is running I wrote the command repair table import; and there I am

  12.   Andrew Cruz said

    Thank you very much, you have saved my skin 😀

  13.   Marco said

    Hello friend, I don't know if you can help me, something similar happened with my website, mark this error:
    The wp_posts table is not right. Report the following error: Table is marked as crashed and last repair failed. WordPress will try to repair this table ...
    Failed to repair wp_posts table. Error: Table is marked as crashed and last repair failed

    I don't know if you can help me fix it, I'm new to advanced WordPress. When trying to repair the wp-post table, it shows an error that it cannot be repaired. Thank you. My website is: https://diarionoticiasweb.com