4

查看mysql已经执行过的sql语句

 3 years ago
source link: https://www.wencst.com/archives/437
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

查看mysql已经执行过的sql语句

作者: wencst 分类: Uncategorized,数据库 发布时间: 2017-01-11 17:16 阅读: 2,729 次

概述

很多时候,我们需要知道 MySQL 执行过哪些 SQL 语句,比如 MySQL 被注入后,需要知道造成什么伤害等等。只要有 SQL 语句的记录,就能知道情况并作出对策。服务器是可以开启 MySQL 的 SQL 语句记录功能,从而就能间接地检测到客户端程序的行为。

方法

开启方法很简单:编辑/etc/my.cnf文件,在[mysqld]节下面添加:log=/var/lib/mysql/sql_row.log行(日志的路径自己根据需要定义)。

代码如下:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
log=/var/lib/mysql/sql_row.log
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

修改完毕后,记得重启 MySQL:

代码如下:
service mysql restart
# 或者
/etc/init.d/mysqld stop
/etc/init.d/mysqld start

如果文章对您有用,扫一下支付宝的红包,不胜感激!

欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK