Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.6Mb
PDF (A4) - 31.6Mb
PDF (RPM) - 30.5Mb
HTML Download (TGZ) - 7.6Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.5Mb
Man Pages (TGZ) - 189.6Kb
Man Pages (Zip) - 304.2Kb
Info (Gzip) - 3.0Mb
Info (Zip) - 3.0Mb
Excerpts from this Manual

MySQL 5.6 Reference Manual  /  ...  /  Audit Log Reference

6.5.4.6 Audit Log Reference

The following discussion serves as a reference to MySQL Enterprise Audit components:

6.5.4.6.1 Audit Log Option and Variable Reference

Table 6.17 Audit Log Option and Variable Reference

NameCmd-LineOption FileSystem VarStatus VarVar ScopeDynamic
audit-logYesYes    
audit_log_buffer_sizeYesYesYes GlobalNo
audit_log_connection_policyYesYesYes GlobalYes
audit_log_current_session  Yes BothNo
Audit_log_current_size   YesGlobalNo
Audit_log_event_max_drop_size   YesGlobalNo
Audit_log_events   YesGlobalNo
Audit_log_events_filtered   YesGlobalNo
Audit_log_events_lost   YesGlobalNo
Audit_log_events_written   YesGlobalNo
audit_log_exclude_accountsYesYesYes GlobalYes
audit_log_fileYesYesYes GlobalNo
audit_log_flush  Yes GlobalYes
audit_log_formatYesYesYes GlobalNo
audit_log_include_accountsYesYesYes GlobalYes
audit_log_policyYesYesYes GlobalVaries
audit_log_rotate_on_sizeYesYesYes GlobalYes
audit_log_statement_policyYesYesYes GlobalYes
audit_log_strategyYesYesYes GlobalNo
Audit_log_total_size   YesGlobalNo
Audit_log_write_waits   YesGlobalNo

6.5.4.6.2 Audit Log Options and System Variables

This section describes the command options and system variables that control operation of MySQL Enterprise Audit. If values specified at startup time are incorrect, the audit log plugin may fail to initialize properly and the server does not load it. In this case, the server may also produce error messages for other audit log settings because it will not recognize them.

To control the activation of the audit log plugin, use this option:

If the audit log plugin is enabled, it exposes several system variables that permit control over logging:

mysql> SHOW VARIABLES LIKE 'audit_log%';
+-----------------------------+--------------+
| Variable_name               | Value        |
+-----------------------------+--------------+
| audit_log_buffer_size       | 1048576      |
| audit_log_connection_policy | ALL          |
| audit_log_current_session   | ON           |
| audit_log_exclude_accounts  |              |
| audit_log_file              | audit.log    |
| audit_log_flush             | OFF          |
| audit_log_format            | OLD          |
| audit_log_include_accounts  |              |
| audit_log_policy            | ALL          |
| audit_log_rotate_on_size    | 0            |
| audit_log_statement_policy  | ALL          |
| audit_log_strategy          | ASYNCHRONOUS |
+-----------------------------+--------------+

You can set any of these variables at server startup, and some of them at runtime.

  • audit_log_buffer_size

    Introduced5.6.10
    Command-Line Format--audit-log-buffer-size=value
    System VariableNameaudit_log_buffer_size
    ScopeGlobal
    DynamicNo
    Permitted Values (32-bit platforms)Typeinteger
    Default1048576
    Minimum4096
    Maximum4294967295
    Permitted Values (64-bit platforms)Typeinteger
    Default1048576
    Minimum4096
    Maximum18446744073709547520

    When the audit log plugin writes events to the log asynchronously, it uses a buffer to store event contents prior to writing them. This variable controls the size of that buffer, in bytes. The server adjusts the value to a multiple of 4096. The plugin uses a single buffer, which it allocates when it initializes and removes when it terminates. The plugin allocates this buffer only if logging is asynchronous.

  • audit_log_connection_policy

    Introduced5.6.20
    Command-Line Format--audit-log-connection-policy=value
    System VariableNameaudit_log_connection_policy
    ScopeGlobal
    DynamicYes
    Permitted ValuesTypeenumeration
    DefaultALL
    Valid ValuesALL
    ERRORS
    NONE

    The policy controlling how the audit log plugin writes connection events to its log file. The following table shows the permitted values.

    ValueDescription
    ALLLog all connection events
    ERRORSLog only failed connection events
    NONEDo not log connection events
    Note

    At server startup, any explicit value given for audit_log_connection_policy may be overridden if audit_log_policy is also specified, as described in Section 6.5.4.4, “Audit Log Logging Control”.

  • audit_log_current_session

    Introduced5.6.20
    System VariableNameaudit_log_current_session
    ScopeGlobal, Session
    DynamicNo
    Permitted ValuesTypeboolean
    Defaultdepends on filtering policy

    Whether audit logging is enabled for the current session. The session value of this variable is read only. It is set when the session begins based on the values of the audit_log_include_accounts and audit_log_exclude_accounts system variables. The audit log plugin uses the session value to determine whether to audit events for the session. (There is a global value, but the plugin does not use it.)

  • audit_log_exclude_accounts

    Introduced5.6.20
    Command-Line Format--audit-log-exclude-accounts=value
    System VariableNameaudit_log_exclude_accounts
    ScopeGlobal
    DynamicYes
    Permitted ValuesTypestring
    DefaultNULL

    The accounts for which events should not be logged. The value should be NULL or a string containing a list of one or more comma-separated account names. For more information, see Section 6.5.4.5, “Audit Log Filtering”.

    Modifications to audit_log_exclude_accounts affect only connections created subsequent to the modification, not existing connections.

  • audit_log_file

    Introduced5.6.10
    Command-Line Format--audit-log-file=file_name
    System VariableNameaudit_log_file
    ScopeGlobal
    DynamicNo
    Permitted ValuesTypefile name
    Defaultaudit.log

    The name of the file to which the audit log plugin writes events. The default value is audit.log. If the value of audit_log_file is a relative path name, the plugin interprets it relative to the data directory. If the value is a full path name, the plugin uses the value as is. A full path name may be useful if it is desirable to locate audit files on a separate file system or directory. For security reasons, the audit log file should be written to a directory accessible only to the MySQL server and to users with a legitimate reason to view the log. For more information, see Section 6.5.4.4, “Audit Log Logging Control”.

  • audit_log_flush

    Introduced5.6.10
    System VariableNameaudit_log_flush
    ScopeGlobal
    DynamicYes
    Permitted ValuesTypeboolean
    DefaultOFF

    When this variable is set to enabled (1 or ON), the audit log plugin closes and reopens its log file to flush it. (The value remains OFF so that you need not disable it explicitly before enabling it again to perform another flush.) Enabling this variable has no effect unless audit_log_rotate_on_size is 0. For more information, see Section 6.5.4.4, “Audit Log Logging Control”.

  • audit_log_format

    Introduced5.6.14
    Command-Line Format--audit-log-format=value
    System VariableNameaudit_log_format
    ScopeGlobal
    DynamicNo
    Permitted Values (>= 5.6.14)Typeenumeration
    DefaultOLD
    Valid ValuesOLD
    NEW

    The audit log file format. Permitted values are OLD and NEW (default OLD). For details about each format, see Section 6.5.4.3, “Audit Log File Formats”.

    Note

    Changing the value of audit_log_format can result in writing log entries in one format to an existing log file that contains entries in a different format. To avoid this issue, use the procedure described at Audit Log File Format.

  • audit_log_include_accounts

    Introduced5.6.20
    Command-Line Format--audit-log-include-accounts=value
    System VariableNameaudit_log_include_accounts
    ScopeGlobal
    DynamicYes
    Permitted ValuesTypestring
    DefaultNULL

    The accounts for which events should be logged. The value should be NULL or a string containing a list of one or more comma-separated account names. For more information, see Section 6.5.4.5, “Audit Log Filtering”.

    Modifications to audit_log_include_accounts affect only connections created subsequent to the modification, not existing connections.

  • audit_log_policy

    Introduced5.6.10
    Command-Line Format--audit-log-policy=value
    System Variable (<= 5.6.19)Nameaudit_log_policy
    ScopeGlobal
    DynamicYes
    System Variable (>= 5.6.20)Nameaudit_log_policy
    ScopeGlobal
    DynamicNo
    Permitted ValuesTypeenumeration
    DefaultALL
    Valid ValuesALL
    LOGINS
    QUERIES
    NONE

    The policy controlling how the audit log plugin writes events to its log file. The following table shows the permitted values.

    ValueDescription
    ALLLog all events
    LOGINSLog only login events
    QUERIESLog only query events
    NONELog nothing (disable the audit stream)

    As of MySQL 5.6.20, audit_log_policy can be set only at server startup. At runtime, it is a read-only variable. This is due to the introduction of two other system variables, audit_log_connection_policy and audit_log_statement_policy, that provide finer control over logging policy and that can be set either at startup or at runtime. If you continue to use audit_log_policy at startup instead of the other two variables, the server uses its value to set those variables. For more information about the policy variables and their interaction, see Section 6.5.4.4, “Audit Log Logging Control”.

    Before MySQL 5.6.20, the audit_log_connection_policy and audit_log_statement_policy system variables do not exist. audit_log_policy is the only policy control variable and it can be set at server startup or runtime.

  • audit_log_rotate_on_size

    Introduced5.6.10
    Command-Line Format--audit-log-rotate-on-size=N
    System VariableNameaudit_log_rotate_on_size
    ScopeGlobal
    DynamicYes
    Permitted ValuesTypeinteger
    Default0

    If the audit_log_rotate_on_size value is 0, the audit log plugin does not perform automatic log file rotation. Instead, use audit_log_flush to close and reopen the log on demand. In this case, manually rename the file externally to the server before flushing it.

    If the audit_log_rotate_on_size value is greater than 0, automatic size-based log file rotation occurs. Whenever a write to the log file causes its size to exceed the audit_log_rotate_on_size value, the audit log plugin closes the current log file, renames it, and opens a new log file.

    For more information about audit log file rotation, see Audit Log File Space Management and Name Rotation.

    If you set this variable to a value that is not a multiple of 4096, it is truncated to the nearest multiple. (Thus, setting it to a value less than 4096 has the effect of setting it to 0 and no rotation occurs, except manually.)

  • audit_log_statement_policy

    Introduced5.6.20
    Command-Line Format--audit-log-statement-policy=value
    System VariableNameaudit_log_statement_policy
    ScopeGlobal
    DynamicYes
    Permitted ValuesTypeenumeration
    DefaultALL
    Valid ValuesALL
    ERRORS
    NONE

    The policy controlling how the audit log plugin writes statement events to its log file. The following table shows the permitted values.

    ValueDescription
    ALLLog all statement events
    ERRORSLog only failed statement events
    NONEDo not log statement events
    Note

    At server startup, any explicit value given for audit_log_statement_policy may be overridden if audit_log_policy is also specified, as described in Section 6.5.4.4, “Audit Log Logging Control”.

  • audit_log_strategy

    Introduced5.6.10
    Command-Line Format--audit-log-strategy=value
    System VariableNameaudit_log_strategy
    ScopeGlobal
    DynamicNo
    Permitted ValuesTypeenumeration
    DefaultASYNCHRONOUS
    Valid ValuesASYNCHRONOUS
    PERFORMANCE
    SEMISYNCHRONOUS
    SYNCHRONOUS

    The logging method used by the audit log plugin. These strategy values are permitted:

    • ASYNCHRONOUS: Log asynchronously. Wait for space in the output buffer.

    • PERFORMANCE: Log asynchronously. Drop requests for which there is insufficient space in the output buffer.

    • SEMISYNCHRONOUS: Log synchronously. Permit caching by the operating system.

    • SYNCHRONOUS: Log synchronously. Call sync() after each request.

6.5.4.6.3 Audit Log Plugin Status Variables

If the audit log plugin is enabled, it exposes several status variables that provide operational information.


User Comments
Sign Up Login You must be logged in to post a comment.