MySQL Audit日志审计

1、简介mysql

数据库审计可以实时记录网络上的数据库活动,对数据库操做进行细粒度审计的合规性管理,对数据库受到的风险行为进行告警,对攻击行为进行阻断,它经过对用户访问数据库行为的记录、分析和汇报,用来帮助用户过后生成合规报告、事故追根溯源,同时增强内外部数据库网络行为记录,提升数据资产安全。linux

MySQL企业版有此功能,属于收费组件,此测试社会版使用第三方开源插件。git

2、下载地址github

https://bintray.com/mcafee/mysql-audit-plugin/release/1.1.4-725#filessql

或https://github.com/mcafee/mysql-audit数据库

[root@zstedu soft]# unzip audit-plugin-mysql-5.7-1.1.4-725-linux-x86_64.zipjson

 cp libaudit_plugin.so /usr/local/mysql/lib/plugin/安全

chown -R mysql.mysql libaudit_plugin.so网络

chmod -R 755 libaudit_plugin.so 测试

3、命令行安装操做及报错解决

mysql> INSTALL PLUGIN AUDIT SONAME 'libaudit_plugin.so';                       

ERROR 29 (HY000): File 'mysqld' not found (Errcode: 2 - No such file or directory)

mysql> INSTALL PLUGIN AUDIT SONAME '/opt/mysql/mysql-5.7.22-linux-glibc2.12-x86_64/lib/plugin/libaudit_plugin.so';
ERROR 1124 (HY000): No paths allowed for shared library

解决方案:

参考https://blog.csdn.net/qq_35267530/article/details/76242215

https://blog.csdn.net/qq_33020901/article/details/78827375

查看插件功能是否开启

#show variables like ""%audit%;

开启插件功能:

set global audit_json_file=1;

在MySQL数据目录下,会多出一个mysql-audit.json审计日志。

查看mysql-audit.json文件,能够找到操做SQL语句的用户名和IP地址,起到了对操做数据库很好的监控效果。

相关文章
相关标签/搜索