Many MySQL problems require examining MySQL daemon error log, but it is not always obvious where it is. One way to find it is to issue SELECT @@log_error
query. But
We can use the fact that mysqld
uses file descriptor 2 (stderr
) for the error log and the /proc
file system like this:
sudo readlink /proc/$(pidof mysqld)/fd/2
this, of course, requires a currently running server. File descriptor is guaranteed to be 2 because MySQL writes to the error log via the redirection of the stderr stream to the specified log on startup, and then writing to stderr - at least in versions 5.5 and earlier, likely in later versions as well.