Article

  • 8 years

    8 years

    YetiShare / Core

    2346

MySQL Attempt to Fix a Corrupt Database

Useful commands for repairing a corrupt database:


Start MySQL in safe mode (if not starting normal):

mysqld_safe --skip-grant-tables &

Backup the database:

mysqldump -uroot -p database > database.sql

If errors similar to:

Got error: 145: Table './yetidata/sessions' is marked as crashed and should be repaired when using LOCK TABLES

Fix the table:

mysql -uroot -p
use yetidata;
repair table sessions;

Try the above mysqldump again until the table is fully repaired and backed up.

Exit mysqld_safe and attempt to start mysql as normal:

sudo /etc/init.d/mysqld restart