1

How to modify the system variable audit_log_format to change to JSON format. The variable is read-only and cannot be changed when the server is running.

mysql> SHOW variables LIKE 'audit%';
+-----------------------------+---------------+
| Variable_name               | Value         |
+-----------------------------+---------------+
| audit_log_buffer_size       | 1048576       |
| audit_log_exclude_accounts  |               |
| audit_log_exclude_commands  |               |
| audit_log_exclude_databases |               |
| audit_log_file              | audit.log     |
| audit_log_flush             | OFF           |
| audit_log_format            | OLD           |
| audit_log_handler           | FILE          |
| audit_log_include_accounts  |               |
| audit_log_include_commands  |               |
| audit_log_include_databases |               |
| audit_log_policy            | ALL           |
| audit_log_rotate_on_size    | 0             |
| audit_log_rotations         | 0             |
| audit_log_strategy          | ASYNCHRONOUS  |
| audit_log_syslog_facility   | LOG_USER      |
| audit_log_syslog_ident      | percona-audit |
| audit_log_syslog_priority   | LOG_INFO      |
+-----------------------------+---------------+
18 rows in set (0.00 sec)

I edit my my.cnf in this way, but it doesnt work

bash-4.4$ cat ./etc/my.cnf
#
# The Percona Server 5.7 configuration file.
#
#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#   Please make any edits and changes to the appropriate sectional files
#   included below.
#
!includedir /etc/my.cnf.d/
!includedir /etc/percona-server.conf.d/

[mysqld]
## Audit Logging ##
audit_log_format=JSON
LvyIN
  • 11
  • 1
  • Your config is correct. I suppose you are running docker. Are you sure you have fixed `my.cnf` before MySQL starts? Please, give a sequence of steps you've run to check it's not working. – Pavel Sapezhko Nov 01 '21 at 10:11

1 Answers1

0

The audit plugin is need to be loaded at first.

[mysqld]
plugin-load="audit_log=audit_log.so"
audit_log_policy=ALL
audit_log_format=JSON
audit_log_rotate_on_size=1024M
audit_log_rotations=10
yangs
  • 76
  • 1
  • 3