yum instrall unzip && unzip audit-plugin-mysql-5.7-1.1.7-866-linux-x86_64.zip
mysql> show global variables like 'plugin_dir';
+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| plugin_dir | /usr/lib64/mysql/plugin/ |
+---------------+--------------------------+
1 row in set (0.00 sec)
cp -rf /audit-plugin-mysql-5.7-1.1.7-866/lib/libaudit_plugin.so /usr/lib64/mysql/plugin/ && chmod +x /usr/lib64/mysql/plugin/libaudit_plugin.so
cd /audit-plugin-mysql-5.7-1.1.7-866/utils && chmod +x /audit-plugin-mysql-5.7-1.1.7-866/utils/offset-extract.sh
[root@web utils]# ./offset-extract.sh /usr/sbin/mysqld
//offsets for: /usr/sbin/mysqld (5.7.25)
{"5.7.25","a54988b2de26ea37c2601aa40ae478bb", 7824, 7872, 3632, 4792, 456, 360, 0, 32, 64, 160, 536, 7988, 4360, 3648, 3656, 3660, 6072, 2072, 8, 7056, 7096, 7080, 13472, 148, 672},
audit_offsets=7824, 7872, 3632, 4792, 456, 360, 0, 32, 64, 160, 536, 7988, 4360, 3648, 3656, 3660, 6072, 2072, 8, 7056, 7096, 7080, 13472, 148, 672
plugin-load=AUDIT=libaudit_plugin.so
audit_json_file=on
audit_record_cmds='insert,delete,update,create,drop,alter,grant,truncate'
general_log=ON
mysql> show plugins;
| ngram | ACTIVE | FTPARSER | NULL | GPL |
| AUDIT | ACTIVE | AUDIT | libaudit_plugin.so | GPL |
mysql> SHOW GLOBAL VARIABLES LIKE '%audi%';
mysql> Show variables like "audit_json_file";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| audit_json_file | ON |
+-----------------+-------+
1 row in set (0.00 sec)
查看数据存储目录
mysql> show global variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.00 sec)
tail -f /var/lib/mysql/mysql-audit.json
mysql> show global variables like 'audit_record_cmds';
+-------------------+-------------------------------------------------------+
| Variable_name | Value |
+-------------------+-------------------------------------------------------+
| audit_record_cmds | insert,delete,update,create,drop,alter,grant,truncate |
+-------------------+-------------------------------------------------------+
1 row in set (0.00 sec)