用Tcpdump抓取MySQL执行的SQL

xiaoxiao2021-03-01  16

编写脚本文件dumpsql.sh,内容如下:

!/bin/bashtcpdump -i eth0 -s 0 -l -w out.log port 3306 | strings | perl -e '#!/bin/bashwhile(<>) { chomp; next if /^[^ ]+[ ]*$/;if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i) {if (defined $q) { print "$q/n" ; }$q=$_;} else {$_ =~ s/^[ /t]+//; $q.=" $_" ;}}'

运行并抓去sql的执行。

抓取后在当前目录出现out.log文件,执行strings out.log即可看到sql的运行情况。

相关资源:Office2016专业增强版中文免费正式版(附安装教程)64位
转载请注明原文地址: https://www.6miu.com/read-4200090.html

最新回复(0)