如何安装Mysql的审计插件

背景

    最近项目要验收了,数据库的一个验收标准就是要有数据库审计,所以参照资料安装了Mysql的审计插件。

正文

一、下载插件

下载地址:https://bintray.com/mcafee/mysql-audit-plugin/release/1.1.4-725#files

可选择对应MySQL5.7数据库的最新审计插件,这里以audit-plugin-mysql-5.7-1.1.7-805-linux-x86_64.zip为例。

二、解压插件

[root@mysql]#unzip audit-plugin-mysql-5.7-1.1.7-805-linux-x86_64.zip
[root@mysql]#cp audit-plugin-mariadb-10.2-1.1.4-725/lib/libaudit_plugin.so [root@mysql]#/usr/local/mysql/plugin/
[root@mysql]#chmod +x libaudit_plugin.so
[root@mysql]#chown mysql:mysql libaudit_plugin.so

 

​​​​​​​三、登录数据库进行安装

mysql> install plugin audit soname 'libaudit_plugin.so';

如果报错信息如下:

ERROR 1123 (HY000): Can't initialize function 'audit'; Plugin initialization function failed.

解决办法:

1)授权,加载

[root@mysql]#cd audit-plugin-mysql-5.7-1.1.4-725/utils

[root@mysql]#chmod +x offset-extract.sh

[root@mysql]#./offset-extract.sh /usr/local/mysql/bin/mysqld

2)编辑/etc/my.cnf

plugin-load=audit=libaudit_plugin.so

audit_offsets = 7824, 7872, 3632, 4792, 456, 360, 0, 32, 64, 160, 536, 7988, 4360, 3648, 3656, 3660, 6072, 2072, 8, 7056, 7096, 7080

audit_json_file = on

audit_record_cmds = 'insert,delete,update,create,drop,alter,grant,truncate'

其中audit_offsets的内容,可以根据执行offset-extract.sh脚本的结果来配置,每个版本有一些差异

3)重启mysql

[root@mysql]#/etc/init.d/mysql.service restart

mysql> install plugin audit soname 'libaudit_plugin.so';

​​​​​​​四、查看日志

[root@mysql]# find / -name mysql-audit.json

[root@mysql]# tail -f /usr/local/mysql/mysql-audit.json

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

白杨Shayne

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值