zoukankan      html  css  js  c++  java
  • Mysql 如何开启审计日志功能

    需求

    客户需要查询谁修改、插入、删除的操作记录,通常在没有开启审计功能的话,
    可以利用binlog解析数据获取,但是比较麻烦,今天给大家介绍一个mysql审计插件。

    一、下载插件:

    https://bintray.com/mcafee/mysql-audit-plugin/release/1.1.7-805#files
    

    二、解压插件复制到mysql lib库插件目录下:

    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
    

    三、数据库中查看mysql的插件目录:

    SHOW GLOBAL VARIABLES LIKE 'plugin_dir'
    

    四、拷贝libaudit_plugin.so到mysql插件目录:

    cp libaudit_plugin.so  /usr/local/mysql/lib/plugin/
    chmod +x libaudit_plugin.so
    chown mysql:mysql libaudit_plugin.so
    

    五、mysql命令行安装libaudit_plugin.so:

    install plugin audit soname 'libaudit_plugin.so';
    

    六、开启设计功能

    set global audit_json_file=1;
    

    七、添加配置到 mysql 配置文件

    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;
    

  • 相关阅读:
    Python3.4 多线程
    OSG Win7 + VS2015 编译
    OSG-3.4.0 简要说明(Readme)
    Boost 1.62.0 编译参数
    VS2015 + QT5.7 中文的坑
    C++库编译
    osg学习笔记3 简单几何模型
    Sqlserver 创建账号
    nginx检查报错:nginx: [emerg] "server" directive is not allowed here in
    Linux修改挂载目录名称
  • 原文地址:https://www.cnblogs.com/syy1757528181/p/14480232.html
Copyright © 2011-2022 走看看