Uno puede iniciar sesión connect
y quit
ordenar usando mysql-audit-plugin.
- Encuentre la versión correcta del lanzamiento de mysql-audit-plugin , usé mysql 5.7, así que usé
audit-plugin-percona-5.7-1.1.7-805-linux-x86_64.zip
.
- reubique el
so
archivo descargado en el lugar dado por mysqladmin variables | grep plugin_dir
.
mysql>install plugin audit soname 'libaudit_plugin.so'
- activando la función de registro
mysql>set global audit_json_file=ON
, por defecto registra todas las operaciones exitosas. configurando los set global audit_record_cmds='quit,connect'
registros solo se conecta y se cierra, supongo, de acuerdo con la configuración de mysql-audit-plugin .
Así es como se ve en el archivo para iniciar y cerrar sesión:
{"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"}