On peut se connecter connect
et quit
commander en utilisant mysql-audit-plugin.
- Trouvez la bonne version de la version mysql-audit-plugin , j'ai utilisé mysql 5.7, donc j'ai utilisé
audit-plugin-percona-5.7-1.1.7-805-linux-x86_64.zip
.
- déplacer le
so
fichier téléchargé à l'endroit indiqué par mysqladmin variables | grep plugin_dir
.
mysql>install plugin audit soname 'libaudit_plugin.so'
- en activant la fonction de journal
mysql>set global audit_json_file=ON
, par défaut, il enregistre toutes les opérations réussies. en le paramétrant, set global audit_record_cmds='quit,connect'
il se connecte uniquement et se ferme, je suppose, selon la configuration de mysql-audit-plugin .
Voici à quoi cela ressemble dans le fichier pour la connexion et la déconnexion:
{"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"}