Man kann sich mit dem mysql-audit-plugin anmelden connect
und quit
befehlen.
- Finden Sie die richtige Version von MySQL-Audit-Plugin Release , ich habe MySQL 5.7 verwendet, also habe ich verwendet
audit-plugin-percona-5.7-1.1.7-805-linux-x86_64.zip
.
- Verschieben Sie die heruntergeladene
so
Datei an den von angegebenen Ort mysqladmin variables | grep plugin_dir
.
mysql>install plugin audit soname 'libaudit_plugin.so'
- Einschalten Log - Funktion,
mysql>set global audit_json_file=ON
wird standardmäßig protokolliert er alle erfolgreichen Operationen. Durch das Setzen von set global audit_record_cmds='quit,connect'
Protokollen werden vermutlich nur Verbindungen hergestellt und beendet, je nach Konfiguration des mysql-audit-plugins .
So sieht es in der Datei zum An- und Abmelden aus:
{"msg-type":"activity","date":"1543740612328","thread-id":"1015112","query-id":"3045222","user":"root","priv_user":"skip-grants user","ip":"172.28.15.10","host":"172.28.15.10","connect_attrs":{"_os":"Linux","_client_name":"libmysql","_pid":"11575","_client_version":"5.6.40","_platform":"x86_64","program_name":"mysql"},"cmd":"Quit","query":"Quit"}
{"msg-type":"activity","date":"1543740724627","thread-id":"1015113","query-id":"0","user":"root","priv_user":"skip-grants user","ip":"172.28.15.10","host":"172.28.15.10","connect_attrs":{"_os":"Linux","_client_name":"libmysql","_pid":"11863","_client_version":"5.6.40","_platform":"x86_64","program_name":"mysql"},"cmd":"Connect","query":"Connect"}
{"msg-type":"activity","date":"1543740724629","thread-id":"1015113","query-id":"3045223","user":"root","priv_user":"skip-grants user","ip":"172.28.15.10","host":"172.28.15.10","connect_attrs":{"_os":"Linux","_client_name":"libmysql","_pid":"11863","_client_version":"5.6.40","_platform":"x86_64","program_name":"mysql"},"rows":"1","status":"0","cmd":"select","query":"select @@version_comment limit 1"}