Thursday, 19 December 2019

mysqlcheck - mysql repair tables

With a recent OS upgrade, some of the mysql database tables got corrupted. Below is how I was able to get it repaired.
  1. Stop mysql server.
  2. Once mysql server is stopped, run a repair on all of *.MYI files via myisamchk:
    # myisamchk -r /var/lib/mysql/*/*.MYI
  3. Bring up the mysql server.
  4. Run a mysqlcheck of all databases via:
    # mysqlcheck -c --all-databases | tee /tmp/dbcheck.log
  5. Grep for "error" on the log and proceed to create a sql file to be run to repair the tables.
    # grep error -B1 /tmp/dbcheck.log | grep -v "error\|--" | sed 's/\(.*\)/REPAIR TABLE \1;/' >/tmp/dbrepair.sql
  6. The file output should be something like:
    REPAIR TABLE database1.table1;
    REPAIR TABLE database1.table2;
    REPAIR TABLE database2.table1;
  7. Log into mysql and source the repair script:
    # mysql> source /tmp/dbrepair.sql
  8. That should run and repair all of the corrupted tables. Verify by running another check and maybe an extended one.
    # mysqlcheck -c -e --all-databases

2 comments:

  1. Your Affiliate Money Making Machine is waiting -

    Plus, making money online using it is as simple as 1..2..3!

    It's super easy how it works...

    STEP 1. Input into the system which affiliate products the system will advertise
    STEP 2. Add some PUSH button traffic (it LITERALLY takes JUST 2 minutes)
    STEP 3. See how the affiliate products system grow your list and upsell your affiliate products all on it's own!

    Are you ready???

    You can test-drive the system for yourself risk free...

    ReplyDelete
  2. If you're looking to lose weight then you need to jump on this brand new personalized keto diet.

    To design this keto diet service, certified nutritionists, fitness trainers, and professional cooks united to develop keto meal plans that are efficient, painless, money-efficient, and fun.

    Since their grand opening in early 2019, 1000's of clients have already completely transformed their figure and health with the benefits a good keto diet can give.

    Speaking of benefits; in this link, you'll discover 8 scientifically-confirmed ones given by the keto diet.

    ReplyDelete