mysql小技巧-防止误删以及日志突然暴增如何分析

sql_safe_updates:控制权限,防止误删除。

开启这个功能:

1.set global sql_safe_updates=1;

重新登录:

mysql> delete from itpuxfg4;

ERROR 1175 (HY000): You are using safe update mode and you tried to update

a table without a where that uses a key column

2.mysql -uroot -p --safe-updates -- 不能加入到my.cnf 里面。

场景:日志突然增大,分析为什么?

针对binlog 日志对表的增删改统计分析:

mysqlbinlog --no-defaults --base64-output=decode-rows -vv itpuxdb-binlog.000002| awk '/UPDATE|INSERT|DELETE/{gsub("###","");gsub("INSERT.*INTO","INSERT");

gsub("DELETE.*FROM","DELETE");count[$1" "$2]++}END{for(i in count)print i,"\t",count[i]}' |sort -k3nr|head -n 10

猜你喜欢

转载自blog.csdn.net/ichglauben/article/details/81428900
今日推荐