Documentation Home
MySQL 9.1 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.4Mb
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.1 Reference Manual  / ...  / MySQL Server Administration  / Debugging MySQL  / Debugging a MySQL Server  /  Using Server Logs to Find Causes of Errors in mysqld

7.9.1.6 Using Server Logs to Find Causes of Errors in mysqld

Note that before startingmysqld with the general query log enabled, you should check all your tables withmyisamchk. SeeChapter 7,MySQL Server Administration.

Ifmysqld dies or hangs, you should startmysqld with the general query log enabled. SeeSection 7.4.3, “The General Query Log”. Whenmysqld dies again, you can examine the end of the log file for the query that killedmysqld.

If you use the default general query log file, the log is stored in the database directory ashost_name.log In most cases it is the last query in the log file that killedmysqld, but if possible you should verify this by restartingmysqld and executing the found query from themysql command-line tools. If this works, you should also test all complicated queries that did not complete.

You can also try the commandEXPLAIN on allSELECT statements that takes a long time to ensure thatmysqld is using indexes properly. SeeSection 15.8.2, “EXPLAIN Statement”.

You can find the queries that take a long time to execute by startingmysqld with the slow query log enabled. SeeSection 7.4.5, “The Slow Query Log”.

If you find the textmysqld restarted in the error log (normally a file namedhost_name.err) you probably have found a query that causesmysqld to fail. If this happens, you should check all your tables withmyisamchk (seeChapter 7,MySQL Server Administration), and test the queries in the MySQL log files to see whether one fails. If you find such a query, try first upgrading to the newest MySQL version. If this does not help, report a bug, seeSection 1.6, “How to Report Bugs or Problems”.

If you have startedmysqld with themyisam_recover_options system variable set, MySQL automatically checks and tries to repairMyISAM tables if they are marked as 'not closed properly' or 'crashed'. If this happens, MySQL writes an entry in thehostname.err file'Warning: Checking table ...' which is followed byWarning: Repairing table if the table needs to be repaired. If you get a lot of these errors, withoutmysqld having died unexpectedly just before, then something is wrong and needs to be investigated further. SeeSection 7.1.7, “Server Command Options”.

When the server detectsMyISAM table corruption, it writes additional information to the error log, such as the name and line number of the source file, and the list of threads accessing the table. Example:Got an error from thread_id=1, mi_dynrec.c:368. This is useful information to include in bug reports.

It is not a good sign ifmysqld did die unexpectedly, but in this case, you should not investigate theChecking table... messages, but instead try to find out whymysqld died.