In the past, the official general.log log from Mysql had the worst performance compared to other plug-ins. We considered the better plug-in in the industry to be MariaDB Audit Plugin, but unfortunately it is not compatible with mysql 5.7 and mysql 8.0 or above.
Using github open source project, the project supports MySQL 5.7 and MySQL 8.0 branches.
https://github.com/Vettabase/audit-plugin-for-mysql
The installation steps are as follows:
Find the plugin directory and copyserver_audit.so
to the plugin directory:
mysql> show variables like 'plugin_dir';
+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| plugin_dir | /usr/lib64/mysql/plugin/ |
+---------------+--------------------------+
1 row in set (0.00 sec)
Turn on the plugin:
Add configuration items in themy.cnf
configuration file and restart MySQL to take effect, or run it in the MySQL command line consoleMake the plug-in take effect immediately. plugin_load_add = server_audit.so
INSTALL PLUGIN server_audit SONAME 'server_audit.so';
Check audit status:
mysql> show variables like '%server_audit%';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| server_audit_events | |
| server_audit_excl_users | |
| server_audit_file_path | server_audit.log |
| server_audit_file_rotate_now | OFF |
| server_audit_file_rotate_size | 1000000 |
| server_audit_file_rotations | 9 |
| server_audit_incl_users | |
| server_audit_loc_info | |
| server_audit_logging | ON |
| server_audit_output_type | file |
| server_audit_query_log_limit | 1024 |
| server_audit_syslog_facility | LOG_USER |
| server_audit_syslog_ident | mysql-server_auditing |
| server_audit_syslog_info | |
| server_audit_syslog_priority | LOG_INFO |
+-------------------------------+-----------------------+
15 rows in set (0.00 sec)
server_audit.log
defaults to thedatadir
directory.