转载自:https://blog.51cto.com/13941177/2173086

注意:

安装插件的方式优缺点:

缺点:日志信息比较大,对性能影响大。

优点:对每一时刻每一用户的操作都有记录。

搭建过程:

到网站(https://bintray.com/version/files/mcafee/mysql-audit-plugin/release/1.1.7-805)下载插件audit-plugin-mysql-5.7-1.1.7-805-linux-x86_64.zip

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

1、把文件上传到/opt目录下

[root@edu-mysql-02 ~]# cd /opt/

[root@edu-mysql-02 opt]# unzip audit-plugin-mariadb-10.2-1.1.4-725-linux-x86_64.zip

2、登录数据库,查看存放路径

mysql> show global variables like 'plugin_dir';

[root@edu-mysql-02 opt]# cp audit-plugin-mariadb-10.2-1.1.4-725/lib/libaudit_plugin.so /usr/lib64/mysql/plugin/

[root@edu-mysql-02 opt]# cd /usr/lib64/mysql/plugin/

授权:

[root@edu-mysql-02 plugin]# chmod +x libaudit_plugin.so

[root@edu-mysql-02 plugin]# chown mysql:mysql libaudit_plugin.so

3、登录数据库进行安装

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

报错信息如下:

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

解决办法:

1)授权,加载

[root@edu-mysql-02 utils]# pwd

/opt/audit-plugin-mysql-5.7-1.1.4-725/utils

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

[root@edu-mysql-02 opt]# which mysqld

/usr/sbin/mysqld

[root@edu-mysql-02 utils]# ./offset-extract.sh /usr/sbin/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

3)重启mysql

[root@edu-mysql-02 utils]# systemctl restart mysqld.service

4、进入mysql安装

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

5、检查:

mysql> show plugins;

检查版本

mysql> show global status like 'AUDIT_version';

开启audit功能:

mysql> SET GLOBAL audit_json_file=ON;

可以查看插件有哪些可配置的参数:

mysql> show variables like '%audit%'\G;

为了保证重启数据库,配置不丢失,修改my.cnf 配置文件,将下面的配置添加到[mysqld]中,所以在配置文件中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'

查看日志:

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

[root@edu-mysql-02 log]# tail -f /var/lib/mysql/mysql-audit.json

MySQL5.7 (审计)安装audit审计插件的更多相关文章

  1. MySQL审计工具Audit Plugin安装使用

    本实验的审计插件均是安装在 mysql-community-server-5.7.9 的服务器上. 插件安装(社区版) 插件下载地址: https://bintray.com/mcafee/mysql ...

  2. Oracle Audit 审计功能的认识与使用

    1.Audit的概念 Audit是监视和记录用户对数据库进行的操作,以供DBA进行问题分析.利用Audit功能,可以完成以下任务: 监视和收集特定数据库活动的数据.例如管理员能够审计哪些表被更新,在某 ...

  3. Oracle11g温习-第十九章:审计(audit)

    2013年4月27日 星期六 10:52 1.审计的功能:监控用户在database 的 action (操作) 2.审计分类 1) session :在同一个session,相同的语句只产生一个审计 ...

  4. ORACLE AUDIT 审计

    转自 http://blog.csdn.net/dnnyyq/article/details/4525980 1.什么是审计 审计(Audit)用于监视用户所执行的数据库操作,并且Oracle会将审计 ...

  5. SQL Server 审计(Audit)

    审计(Audit)用于追踪和记录SQL Server实例,或者单个数据库中发生的事件(Event),审计运作的机制是通过捕获事件(Event),把事件包含的信息写入到事件日志(Event Log)或审 ...

  6. MySQL5.7的安装(CentOS 7 & Ubuntu 16.04)

    CentOS 通过 yum 安装MySQL5.7 Yum Repository 下载地址:https://dev.mysql.com/downloads/repo/yum/ 选择相应的版本进行下载:R ...

  7. centos 7下安装MySQL5.7 的安装和配置

    原文链接:  http://blog.csdn.net/xyang81/article/details/51759200 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置Y ...

  8. CentOS7 64位下 MySQL5.7的安装与配置(YUM)

    趁着11.11的时候在阿里云上弄了一云服务ECS(作为自己的节日礼物 > _ <) ,系统为CentOS的,打算弄一个人博客之类的,这些天正在备案当中(不知得多久). 忙里偷闲,在中午休息 ...

  9. CentOS7服务器中apache、php7以及mysql5.7的安装配置代码

    CentOS7服务器中apache.php7以及mysql5.7的配置代码如下所示: yum upgradeyum install net-tools 安装apache (http://m.86822 ...

随机推荐

  1. GB2312、GBK、GB18030 这几种字符集的主要区别

    1 GB2312-80 GB 2312 或 GB 2312-80 是中国国家标准简体中文字符集,全称<信息交换用汉字编码字符集·基本集>,又称 GB 0,由中国国家标准总局发布,1981 ...

  2. 【转载】【最短路Floyd+KM 最佳匹配】hdu 2448 Mining Station on the Sea

    Mining Station on the Sea Problem Description The ocean is a treasure house of resources and the dev ...

  3. mysql常见内置函数

    在mysql中有许多内置的函数,虽然功能都能在PHP代码中实现,但巧妙的应用mysql内置函数可以大大的简化开发过程,提高效率. 在这里我总结一下一些常用的,方便以后查看: mysql字符串函数: c ...

  4. This is very likely to create a memory leak. Stack trace of thread错误分析

    1.问题描述 启动tomcat部署项目时,报This is very likely to create a memory leak. Stack trace of thread错误. 29-May-2 ...

  5. 利用Filter和HttpServletRequestWrapper实现请求体中token校验

    先说一下项目的背景,系统传参为json格式,token为其中一个必传参数,此时如果在过滤器中直接读取request,则后续controller中通过RequestBody注解封装请求参数是会报stre ...

  6. Myatis之bind标签

    myBatis的bind的标签,一般的用法都是 <if test="name!= null and name!= '' "> <bind name="u ...

  7. Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ResumeForm needs updating.

    django 报错 django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fiel ...

  8. java封装数据类型——Integer

    今天来学习整型 int 的封装数据类型,Integer. 1. 定义 首先来看看定义.可以看到,Integer 继承 Number 抽象类,实现了 Comparable 接口.Number 类是常用数 ...

  9. React/Refs and this DOM

    Refs 提供了一种方式,允许我们访问 DOM 节点或在 render 方法中创建的 React 元素. 何时使用Refs 管理焦点,文本选择或媒体播放. 触发强制动画. 集成第三方 DOM 库. 避 ...

  10. 线段树lazy模板 luogu3372

    线段树写得很少,这么基本的算法还是要会的…… #include<bits/stdc++.h> using namespace std; inline long long read() { ...