0

I have a web application that is crashing at certain intervals. The standard logs are not giving enough information, so I would like to have a log of every MySQL query so I can look at the time stamp and see what query(ies) was(were) running at the time of the crash.

I was unable to find any results in search for how to do this. Can anyone explain how to enable this type of log?

Spencer Hill
  • 1,043
  • 2
  • 15
  • 38
  • 1
    This question belongs on dba.stackexchange.com. Stack Overflow is for questions about specific code problems, but this question is more about MySQL Server configuration. – Bill Karwin Mar 03 '22 at 18:50
  • The short answer: read https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html – Bill Karwin Mar 03 '22 at 18:50
  • follow this answer - https://stackoverflow.com/questions/303994/log-all-queries-in-mysql – Chandan Mar 03 '22 at 19:00
  • 1
    The Slow Query Log records queries when they FINISH with system time which might get you close enough to the real problem. That log is easy, just SET LONG_QUERY_TIME=0; (from a MySQL Command Prompt) and every query will be logged before the instance crashes. If this does not have you covered, what do you mean by 'certain intervals'? – Wilson Hauck Mar 05 '22 at 15:31
  • Thanks @WilsonHauck I'll try this and see if it's sufficient for my needs and then you can repost as an Answer and I'll mark it as completed. – Spencer Hill Mar 07 '22 at 17:07
  • @SpencerHill Thanks, Spencer. Have a great weekend. Will be OOO for a few days. – Wilson Hauck Mar 08 '22 at 13:46

0 Answers0