从general log 中过滤出对于某个特定database的操作

it2022-05-05  233

# NOTE: depending on your version of MySQL ## This example is for mysql 5.4

Shell> for x in var=`cat mysql.log |grep Connect |awk '{print $2}' |cut -d: -f3`; do echo ${var:2:50} >> out.txt; done

I now have all of the connection ids for the database I want to benchmark. From here I need to parse through the mysql.log (the general log) to get the queries that I would like to run with mysqlslap. Here goes:

Shell> for x in `cat ./out.txt`; do cat mysql.log | awk -v x="$x" '{ if ( $1 == x ) { printf("%s ;\n",$0,x) } }' $1; done |awk -FQuery '{print $2 “ ;”}' |grep –v “INSERT” >> myqueries.txt

转载于:https://www.cnblogs.com/buro79xxd/archive/2009/10/09/1682551.html


最新回复(0)