MySQL开启记录执行过的SQL语句方法
概述
很多时候,我们需要知道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 #Defaulttousingoldpasswordformatforcompatibilitywithmysql3.x #clients(thoseusingthemysqlclient10compatibilitypackage). old_passwords=1 log=/var/lib/mysql/sql_row.log #Disablingsymbolic-linksisrecommendedtopreventassortedsecurityrisks; #todoso,uncommentthisline: #symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
修改完毕后,记得重启MySQL:
servicemysqlrestart #或者 /etc/init.d/mysqldstop /etc/init.d/mysqldstart
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短