如何找到MySQL守护程序错误日志的位置? [英] How do I find the location of MySQL daemon error log?

查看:98
本文介绍了如何找到MySQL守护程序错误日志的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多MySQL问题需要检查MySQL守护程序错误日志,但是在哪里并不总是很明显.找到它的一种方法是发出SELECT @@log_error查询.但是,如果您在Linux MySQL服务器主机上具有root shell,又不想连接到服务器,并且需要一种快速而又肮脏的方法来在shell脚本中获取它,该怎么办?

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 what if you have a root shell on a Linux MySQL server host, do not want to connect to the server, and need a quick and dirty way to grab that in a shell script?

推荐答案

我们可以使用以下事实:mysqld将文件描述符2(stderr)用于错误日志和/proc文件系统,如下所示:

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

这当然需要当前正在运行的服务器.文件描述符保证为2,因为MySQL在启动时会通过将stderr流重定向到指定日志来写入错误日志,然后再写入stderr-至少在5.5版或更早的版本中(可能在更高版本中也是如此).

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.

这篇关于如何找到MySQL守护程序错误日志的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆