0

I have a server on Azure with a MySQL database, we have two apps there and sometimes we get this error on the code:

Warning: mysqli::query(): (HY000/1194): 
Table 'noticia' is marked as crashed and should be repaired 
in D:\home\site\wwwroot\classes\ConnectionFactory.php on line 122

Some questions:

  1. What kind of things could cause this error?
  2. Where can I find the logs in order to get the cause of the error?
  3. Could this be could a PHP problem?

This is too strange because I have been using the same ConnectionFactory class to connect to the database for several year and this is the first time that we get this error.

0

I assume this is a MyISAM table. These are not crash safe. InnoDB tables on the other hand, are.

  1. There could be several reasons, such as:

    • disk failure
    • VM reboot or crash
    • mysql daemon crash - open MyISAM tables are likely to crash if the mysql daemon crashes

    See also: Why do MySQL tables crash? How do I prevent it?

  2. The MySQL error log is by default located in the datadir. By default, the file name is the name of the host with the suffix '.err'.

  3. I don't think so, not unless PHP managed to crash the mysql daemon.

You may be able to repair the table by issuing a mysql command like:

REPAIR TABLE your_database_name.noticia;

Or, from the command shell, you can run something like this to check and repair all tables:

mysqlcheck -u root -p --auto-repair --check --all-databases
3
  • Thanks for answering the question. Do you recommend change the table engine to InnDB? Thanks. – leandro2219 Jun 18 '18 at 23:03
  • @leandro2219 Yes, unless there are very specific reasons why you want to use MyISAM. Most of the remaining advantages of MyISAM are gone as of MySQL 5.7 as the features have been implemented in InnoDB. As of MySQL 8.0, MyISAM is on its way out. See e.g. MySQL 8.0: The end of MyISAM (Percona blog). – dbdemon Jun 19 '18 at 9:05
  • Thanks for that I will change the engine of the tables and see if the problem is solved. – leandro2219 Jun 19 '18 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.