How do I find the location of MySQL daemon error log?

前端 未结 1 1254
难免孤独
难免孤独 2021-01-27 13:07

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

1条回答
  •  暖寄归人
    2021-01-27 13:36

    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.

    0 讨论(0)
提交回复
热议问题