Home > Database > Mysql Tutorial > body text

通过日志查看MySQL正在执行的SQL语句

WBOY
Release: 2016-06-07 17:31:11
Original
1066 people have browsed it

在项目开发里面总是要查看后台执行的sql语句,mysql数据库也不例外,它的查看方式大家一般喜欢使用 showprocesslist; 命令来解决

在项目开发里面总是要查看后台执行的sql语句,mysql数据库也不例外,它的查看方式大家一般喜欢使用 showprocesslist; 命令来解决,通过里面输出结果的字段解释中可以分析执行了的sql语句类型,但不太适合一般的初级使用者,,因此通过日志文件查看sql语句是最直接的方法。

首先你需要创建一个日志文件log.txt ,比如我直接保存在mysql目录下的data目录中间,然后只需要在 mysql的配置文件my.cnf 中最后添加

log=/var/log/mysql/mysqlProcess.log

这样可以记录所有的mysql执行的sql语句!

log=/var/log/mysql/mysqlProcess.log

添加在[mysqld]块中

需要手动建立此文件,然后chown mysql:mysql,权限修改为跟mysqld.log相同

推荐阅读:

MySQL视图表创建与修改

MySQL视图(view)

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!