Mysql – Automatic Recovery of MyISAM table

myisamMySQL

I have an application in C language which inserts the report data in MyISAM table by using mysql_stmt_execute() function.
Due to load on the table, it gets crashed.

For auto repair of crashed table, I have added following option in /etc/my.cnf file

myisam-recover-options=FORCE,BACKUP

When the table gets into a crashed state, then mysql_stmt_execute() function fails and I can't insert the reports. As I have specified recovery options, expected result should be, table gets repaired and application should work fine.

QUESTIONS

  • How to repair the table automatically when it gets crashed ?
  • Why myisam-recover-option can't recover the table when query is executed ?

Best Answer

myisam_recover_options is not a dynamic variable. It is among the startup options for MyISAM.

If you have set this option in my.cnf, mysqld must be restarted

Please restart mysqld with

# service mysql restart

or if you have Windows

C:\> net stop mysql
C:\> net start mysql

You should try switching your table to InnoDB and make your table crash-safe.