MySQL社区版本没有自带审计功能,所以基于MySQL8.0.33版本容器运行的MySQL自行安装插件

 因为MySQL社区版本没有自带审计功能,所以基于MySQL8.0.33版本容器运行的MySQL自行安装插件

1.查看Mysql是否安装过audit_log插件

SELECT * FROM information_schema.PLUGINS WHERE PLUGIN_NAME LIKE '%audit%';
 

2.下载Percona Server for MySQL,地址为 Install with binary tarballs - Percona Server for MySQL

 

  1.  
    tar -xvf Percona-Server-8.0.33-25-Linux.x86_64.glibc2.17-minimal.tar.gz
  2.  
    cd Percona-Server-8.0.33-25-Linux.x86_64.glibc2.17-minimal/lib/plugin
  3.  
     
  4.  
    #复制插件audit_log.so到容器内mysql插件目录
  5.  
    docker cp audit_log.so ca92879e02a9:/usr/lib64/mysql/plugin/

3.安装插件

install plugin audit_log soname 'audit_log.so';
 

4.添加配置,在my.cnf中[mysqld]里面添加

  1.  
    plugin-load = audit_log.so
  2.  
    audit_log_file = /var/lib/mysql/audit.log
  3.  
    audit_log_format = JSON
  4.  
    audit_log_policy = ALL
  5.  
    audit_log_handler = FILE
  6.  
    audit_log_rotate_on_size = 1048576

5.重启MySQL容器

docker restart ca92879e02a9
 

 

 
posted @ 2024-05-28 14:52  MaskerFan  阅读(168)  评论(0编辑  收藏  举报