I want to cause the MySQL 5.5 error log to be written to at will without a service stop or start. Note that I do not care what gets written to the error log, as long as something gets written.
I tried running a bad query and setting a nonexistent system variable, but those actions do not seem to generate an entry in the error log.
How can I do this?
Best Answer
Bad queries and other invalid actions typically only write to the error log when there's not a client connection to write the error to... such as when a thread that isn't a client thread encounters an error... or from the event scheduler.
From within a scheduled event,
SIGNAL
can be used to throw errors and warnings that will be written to MySQL's error log. And, of course, you can "schedule" an event to run only once, right now.Alternately, there's a 3rd party user-defined function
log_error()
that can write to the error log: https://github.com/mysqludf/lib_mysqludf_logThat's assuming you're not "really" wanting to trigger MySQL to politely close and reopen the log file... this is done with
FLUSH ERROR LOGS;
.