假设我浏览一个 php 页面,我如何知道运行了哪些数据库查询? 我想如果我可以将所有查询记录到 .txt 文件中,就可以解决我的问题。我尝试登录,但失败了。我只想知道发送给它的查询(sql 字符串)。
我使用的是 WinXP 和 Apache。
最佳答案
一种方法是进入 my.cnf 配置文件并激活常规日志。正如所暗示的,它是一个性能 killer ,所以永远不要在生产中激活它。不过,对于开发来说是完全可以的。我的笔记本电脑一直处于开启状态。
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
general_log_file = /var/log/mysql/mysql.log
general_log = 1
关于php - 如何监控MySQL查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7648729/