经过测试,在完全使用社区版MySQL数据库时,想免费使用审计插件、且没有版本等问题的方法只用通过AWS的开源项目:
https://github.com/aws/audit-plugin-for-mysql
通过从源码修改,然后编译的方式。
#拷贝文件到MySQL源码
rsync -av plugin/ <mysqlSourceFolder>/plugin/
#拷贝测试文件到MySQL源码
rsync -av mysql-test/ <mysqlSourceFolder>/mysql-test/
然后通过CMAKE编译安装MySQL,可以参考
https://mhsxq.com/archives/120
初始化数据库后安装
Place the file server_audit.so in the plugin directory. You can run
SHOW VARIABLES LIKE 'plugin_dir';
to find the correct path.
Activate the plugin by adding
plugin_load_add = server_audit
to my.cnf or by running
INSTALL PLUGIN server_audit SONAME ‘server_audit.so’;
once.
开启插件
set global server_audit_logging=1;
该命令可以实时在线操作。