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

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

问题描述

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

Possible Duplicate:
How to enable MySQL Query Log?

是否可以跟踪MySQL中的每个SQL查询?

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

我正在使用Doctrine ORM来构建实体并从数据库中获取它们,并希望了解Doctrine产生的查询.因此,当我刷新使用Doctrine ORM从数据库中获取某些数据的网页时,在哪里可以看到在数据库中执行的查询?

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?

这可能吗?

推荐答案

让此应用程序确定是否要记录查询,如果要记录所有查询,则在MySQL端记录查询.

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

Doctrine在软件包中具有内置的记录器界面和演示记录器.来自 http://docs.doctrine- project.org/en/2.0.x/reference/configuration.html#sql-logger-optional :

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();

获取或设置记录器以记录由Doctrine执行的所有SQL语句.记录器类必须实现Doctrine \ DBAL \ Logging \ SQLLogger接口.可以在Doctrine \ DBAL \ Logging \ EchoSQLLogger中找到一个使用echo和var_dump记录到标准输出的简单默认实现.

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

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

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