MySQL - 如何跟踪每个查询? [英] MySQL - How to track every query?

查看:17
本文介绍了MySQL - 如何跟踪每个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

可能重复:
如何启用 MySQL 查询日志?

有没有办法跟踪 MySQL 中的每个 SQL 查询?

我正在使用 Doctrine ORM 构建实体并从数据库中获取它们,并且想看看 Doctrine 产生了哪些查询.那么当我刷新一个使用 Doctrine ORM 从数据库中获取一些数据的网页时,我在哪里可以看到在数据库中执行的查询?

这可能吗?

解决方案

让这个应用程序决定是否要记录查询,如果要记录所有查询,请在 MySQL 端记录查询.

Doctrine 在包中有一个内置的记录器接口和一个演示记录器.来自 http://docs.doctrine-project.org/en/2.0.x/reference/configuration.html#sql-logger-optional:

setSQLLogger($logger);$config->getSQLLogger();

<块引用>

获取或设置记录器,用于记录 Doctrine 执行的所有 SQL 语句.记录器类必须实现 DoctrineDBALLoggingSQLLogger 接口.可以在 DoctrineDBALLoggingEchoSQLLogger 中找到使用 echo 和 var_dump 记录到标准输出的简单默认实现.`

Possible Duplicate:
How to enable MySQL Query Log?

Is there a way to track every SQL query in MySQL?

Im using Doctrine ORM to build entities and fetch them from database, and would like to see what queries is Doctrine producing. So when I refresh a webpage that uses Doctrine ORM to fetch some data from database, where could I see queries executed in database?

Is this possible?

解决方案

Let this application decide if you want queries logged and log queries on MySQLs side if you want all queries logged.

Doctrine has a builtin logger interface and a demo logger in the package. From http://docs.doctrine-project.org/en/2.0.x/reference/configuration.html#sql-logger-optional :

<?php
$config->setSQLLogger($logger);
$config->getSQLLogger();

Gets or sets the logger to use for logging all SQL statements executed by Doctrine. The logger class must implement the DoctrineDBALLoggingSQLLogger interface. A simple default implementation that logs to the standard output using echo and var_dump can be found at DoctrineDBALLoggingEchoSQLLogger.`

这篇关于MySQL - 如何跟踪每个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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