客户需要查询谁修改、插入、删除的操作记录,通常在没有开启审计功能的话,
可以利用binlog解析数据获取,但是比较麻烦,今天给大家介绍一个mysql审计插件。
https://bintray.com/mcafee/mysql-audit-plugin/release/1.1.7-805#files
unzip audit-plugin-mysql-5.7-1.1.7-805-linux-x86_64.zip
cd audit-plugin-mysql-5.7-1.1.7-805/lib
SHOW GLOBAL VARIABLES LIKE 'plugin_dir'
cp libaudit_plugin.so /usr/local/mysql/lib/plugin/
chmod +x libaudit_plugin.so
chown mysql:mysql libaudit_plugin.so
install plugin audit soname 'libaudit_plugin.so';
set global audit_json_file=1;
audit_record_cmds='insert,delete,update,create,drop,alter,grant,truncate'
audit_json_file=on #保证mysql重启后自动启动插件
plugin-load=AUDIT=libaudit_plugin.so #防止删除了插件,重启后又会加载
audit_json_log_file=/data/logs/mysql/mysql_audit.json #日志路径
audit_offsets=7824, 7872, 3632, 4792, 456, 360, 0, 32, 64, 160, 536, 7988, 4360, 3648, 3656, 3660, 6072, 2072, 8, 7056, 7096, 7080
SHOW GLOBAL VARIABLES LIKE '%audit%';
show global status like 'AUDIT_version';
show plugins;
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有