Table of Contents
MySQL includes several plugins that implement security features:
Plugins for authenticating attempts by clients to connect to MySQL Server. Plugins are available for several authentication protocols. For general discussion of the authentication process, see Section 5.6, “Pluggable Authentication”. For characteristics of specific authentication plugins, see Section 7.1, “Authentication Plugins”.
(MySQL Enterprise Edition only) MySQL Enterprise Audit, implemented using a server plugin, uses the open MySQL Audit API to enable standard, policy-based monitoring and logging of connection and query activity executed on specific MySQL servers. Designed to meet the Oracle audit specification, MySQL Enterprise Audit provides an out of box, easy to use auditing and compliance solution for applications that are governed by both internal and external regulatory guidelines.
The following sections describe the authentication plugins available in MySQL.
MySQL includes two plugins that implement native authentication;
that is, authentication against passwords stored in the
Password column of the
mysql.user table. This section describes
mysql_native_password, which implements
authentication against the mysql.user table
using the native password hashing method. For information about
mysql_old_password, which implements
authentication using the older (pre-4.1) password hashing
method, see Section 7.1.2, “The Old Native Authentication Plugin”.
For information about these password hashing methods, see
Section 2.2.4, “Password Hashing in MySQL”.
The mysql_native_password native
authentication plugin is backward compatible. Clients older than
MySQL 5.5.7 do not support authentication
plugins but do use the native
authentication protocol, so they can
connect to servers from MySQL 5.5.7 and up.
The following table shows the plugin names on the server and client sides.
Table 7.1 MySQL Native Password Authentication Plugin
| Server-side plugin name | mysql_native_password |
| Client-side plugin name | mysql_native_password |
| Library file name | None (plugins are built in) |
The plugin exists in both client and server form:
The server-side plugin is built into the server, need not be loaded explicitly, and cannot be disabled by unloading it.
The client-side plugin is built into the
libmysqlclient client library as of MySQL
5.5.7 and available to any program linked against
libmysqlclient from that version or
higher.
MySQL client programs use
mysql_native_password by default. The
--default-auth option can be
used as a hint about which client-side plugin the program
can expect to use:
shell> mysql --default-auth=mysql_native_password ...
If an account row specifies no plugin name, the server
authenticates the account using either the
mysql_native_password or
mysql_old_password plugin, depending on
whether the password hash value in the
Password column used native hashing or the
older pre-4.1 hashing method. Clients must match the password in
the Password column of the account row.
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”.
MySQL includes two plugins that implement native authentication;
that is, authentication against passwords stored in the
Password column of the
mysql.user table. This section describes
mysql_old_password, which implements
authentication against the mysql.user table
using the older (pre-4.1) password hashing method. For
information about mysql_native_password,
which implements authentication using the native password
hashing method, see
Section 7.1.1, “The Native Authentication Plugin”. For information
about these password hashing methods, see
Section 2.2.4, “Password Hashing in MySQL”.
Passwords that use the pre-4.1 hashing method are less secure than passwords that use the native password hashing method and should be avoided.
The mysql_old_password native authentication
plugin is backward compatible. Clients older than MySQL 5.5.7 do
not support authentication plugins but do
use the native authentication protocol, so
they can connect to servers from MySQL 5.5.7 and up.
The following table shows the plugin names on the server and client sides.
Table 7.2 MySQL Old Native Authentication Plugin
| Server-side plugin name | mysql_old_password |
| Client-side plugin name | mysql_old_password |
| Library file name | None (plugins are built in) |
The plugin exists in both client and server form:
The server-side plugin is built into the server, need not be loaded explicitly, and cannot be disabled by unloading it.
The client-side plugin is built into the
libmysqlclient client library as of MySQL
5.5.7 and available to any program linked against
libmysqlclient from that version or
higher.
MySQL client programs can use the
--default-auth option to
specify the mysql_old_password plugin as
a hint about which client-side plugin the program can expect
to use:
shell> mysql --default-auth=mysql_old_password ...
If an account row specifies no plugin name, the server
authenticates the account using either the
mysql_native_password or
mysql_old_password plugin, depending on
whether the password hash value in the
Password column used native hashing or the
older pre-4.1 hashing method. Clients must match the password in
the Password column of the account row.
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”.
The PAM authentication plugin is an extension included in MySQL Enterprise Edition, a commercial product. To learn more about commercial products, see http://www.mysql.com/products/.
As of MySQL 5.5.16, MySQL Enterprise Edition includes an authentication plugin that enables MySQL Server to use PAM (Pluggable Authentication Modules) to authenticate MySQL users. PAM enables a system to use a standard interface to access various kinds of authentication methods, such as Unix passwords or an LDAP directory.
The PAM authentication plugin provides these capabilities:
External authentication: The plugin enables MySQL Server to accept connections from users defined outside the MySQL grant tables and that authenticate using methods supported by PAM.
Proxy user support: The plugin can return to MySQL a user
name different from the login user, based on the groups the
external user is in and the authentication string provided.
This means that the plugin can return the MySQL user that
defines the privileges the external PAM-authenticated user
should have. For example, a PAM user named
joe can connect and have the privileges
of the MySQL user named developer.
The PAM authentication plugin has been tested on Linux and Mac OS X.
The PAM plugin uses the information passed to it by MySQL Server
(such as user name, host name, password, and authentication
string), plus whatever method is available for PAM lookup. The
plugin checks the user credentials against PAM and returns
'Authentication succeeded, Username is
or
user_name''Authentication failed'.
The following table shows the plugin and library file names. The
file name suffix might be different on your system. The file
location must be the directory named by the
plugin_dir system variable. For
installation information, see
Section 7.1.3.1, “Installing the PAM Authentication Plugin”.
Table 7.3 MySQL PAM Authentication Plugin
| Server-side plugin name | authentication_pam |
| Client-side plugin name | mysql_clear_password |
| Library file name | authentication_pam.so |
The library file includes only the server-side plugin. As of
MySQL 5.5.10, the client-side plugin is built into the
libmysqlclient client library. See
Section 7.1.5, “The Cleartext Client-Side Authentication Plugin”.
The server-side PAM authentication plugin is included only in MySQL Enterprise Edition. It is not included in MySQL community distributions. The client-side clear-text plugin that communicates with the server-side plugin is built into the MySQL client library and is included in all distributions, including community distributions. This permits clients from any MySQL 5.5.10 or higher distribution to connect to a server that has the server-side plugin loaded.
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”. For proxy user information, see Section 5.7, “Proxy Users”.
The PAM authentication plugin must be located in the MySQL
plugin directory (the directory named by the
plugin_dir system variable).
If necessary, set the value of
plugin_dir at server startup
to tell the server the plugin directory location.
To enable the plugin, start the server with the
--plugin-load option. For
example, put the following lines in your
my.cnf file. If library files have a
suffix different from .so on your system,
substitute the correct suffix.
[mysqld] plugin-load=authentication_pam.so
To verify plugin installation, examine the
INFORMATION_SCHEMA.PLUGINS table
or use the SHOW PLUGINS
statement (see
Obtaining Server Plugin Information). For example:
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS->WHERE PLUGIN_NAME LIKE 'authentication%';+--------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------------+---------------+ | authentication_pam | ACTIVE | +--------------------+---------------+
To associate a MySQL account with the PAM plugin, use the
plugin name authentication_pam in the
IDENTIFIED WITH clause of
CREATE USER or
GRANT statement that creates
the account.
This section describes how to use the PAM authentication plugin to connect from MySQL client programs to the server. It is assumed that the server-side plugin is enabled, as described previously, and that client programs are recent enough to include the client-side plugin.
The client-side plugin with which the PAM plugin communicates simply sends the password to the server in clear text so it can be passed to PAM. This may be a security problem in some configurations, but is necessary to use the server-side PAM library. To avoid problems if there is any possibility that the password would be intercepted, clients should connect to MySQL Server using a secure connection. See Section 7.1.5, “The Cleartext Client-Side Authentication Plugin”.
To refer to the PAM authentication plugin in the
IDENTIFIED WITH clause of a
CREATE USER or
GRANT statement, use the name
authentication_pam. For example:
CREATE USERuserIDENTIFIED WITH authentication_pam AS 'authentication_string';
The authentication string specifies the following types of information:
PAM supports the notion of “service name,” which is a name that the system administrator can use to configure the authentication method for a particular application. There can be several such “applications” associated with a single database server instance, so the choice of service name is left to the SQL application developer. When you define an account that should authenticate using PAM, specify the service name in the authentication string.
PAM provides a way for a PAM module to return to the server a MySQL user name other than the login name supplied at login time. Use the authentication string to control the mapping between login name and MySQL user name. If you want to take advantage of proxy user capabilities, the authentication string must include this kind of mapping.
For example, if the service name is mysql
and users in the root and
users PAM groups should be mapped to the
developer and data_entry
MySQL users, respectively, use a statement like this:
CREATE USER user
IDENTIFIED WITH authentication_pam
AS 'mysql, root=developer, users=data_entry';
Authentication string syntax for the PAM authentication plugin follows these rules:
The string consists of a PAM service name, optionally followed by a group mapping list consisting of one or more keyword/value pairs each specifying a group name and a MySQL user name:
pam_service_name[,group_name=mysql_user_name]...
The plugin parses the authentication string on each login check. To minimize overhead, keep the string as short as possible.
Each
pair must be preceded by a comma.
group_name=mysql_user_name
Leading and trailing spaces not inside double quotation marks are ignored.
Unquoted pam_service_name,
group_name, and
mysql_user_name values can
contain anything except equal sign, comma, or space.
If a pam_service_name,
group_name, or
mysql_user_name value is quoted
with double quotation marks, everything between the
quotation marks is part of the value. This is necessary,
for example, if the value contains space characters. All
characters are legal except double quotation mark and
backslash (\). To include either
character, escape it with a backslash.
If the plugin successfully authenticates a login name, it looks for a group mapping list in the authentication string and, if present, uses it to return a different user name to the MySQL server based on the groups the external user is a member of:
If the authentication string contains no group mapping list, the plugin returns the login name.
If the authentication string does contain a group mapping
list, the plugin examines each
pair in the list from left to right and tries to find a
match for the group_name=mysql_user_namegroup_name value
in a non-MySQL directory of the groups assigned to the
authenticated user and returns
mysql_user_name for the first
match it finds. If the plugin finds no match for any
group, it returns the login name. If the plugin is not
capable of looking up a group in a directory, it ignores
the group mapping list and returns the login name.
The following sections describe how to set up several authentication scenarios that use the PAM authentication plugin:
No proxy users. This uses PAM only to check login names
and passwords. Every external user permitted to connect to
MySQL Server should have a matching MySQL account that is
defined to use external PAM authentication. (For a MySQL
account of
to match the external user,
user_name@host_nameuser_name must be the login
name and host_name must match
the host from which the client connects.) Authentication
can be performed by various PAM-supported methods. The
discussion shows how to use traditional Unix passwords and
LDAP.
PAM authentication, when not done through proxy users or groups, requires the MySQL account to have the same user name as the Unix account. Because MySQL user names are limited to 16 characters (see Section 4.2, “Grant Tables”), this limits PAM nonproxy authentication to Unix accounts with names of at most 16 characters.
Proxy login only and group mapping. For this scenario, create one or a few MySQL accounts that define different sets of privileges. (Ideally, nobody should connect using those accounts directly.) Then define a default user authenticating through PAM that uses some mapping scheme (usually by the external groups the users are in) to map all the external logins to the few MySQL accounts holding the privilege sets. Any user that logs in is mapped to one of the MySQL accounts and uses its privileges. The discussion shows how to set this up using Unix passwords, but other PAM methods such as LDAP could be used instead.
Variations on these scenarios are possible. For example, you can permit some users to log in directly (without proxying) but require others to connect through proxy users.
The examples make the following assumptions. You might need to make some adjustments if your system is set up differently.
The PAM configuration directory is
/etc/pam.d.
The PAM service name is mysql, which
means that you must set up a PAM file named
mysql in the PAM configuration
directory (creating the file if it does not exist). If you
use a service name different from
mysql, the file name will be different
and you must use a different name in the AS
' clause
of auth_string'CREATE USER and
GRANT statements.
The examples use a login name of
antonio and password of
verysecret. Change these to correspond
to the users you want to authenticate.
The PAM authentication plugin checks at initialization time
whether the AUTHENTICATION_PAM_LOG
environment value is set in the server's startup environment.
If so, the plugin enables logging of diagnostic messages to
the standard output. Depending on how your server is started,
the message might appear on the console or in the error log.
These messages can be helpful for debugging PAM-related
problems that occur when the plugin performs authentication.
For more information, see
Section 7.1.3.6, “PAM Authentication Plugin Debugging”.
This authentication scenario uses PAM only to check Unix user login names and passwords. Every external user permitted to connect to MySQL Server should have a matching MySQL account that is defined to use external PAM authentication.
Verify that Unix authentication in PAM permits you to log
in as antonio with password
verysecret.
Set up PAM to authenticate the mysql
service by creating a file named
/etc/pam.d/mysql. The file contents
are system dependent, so check existing login-related
files in the /etc/pam.d directory to
see what they look like. On Linux, the
mysql file might look like this:
#%PAM-1.0 auth include password-auth account include password-auth
For Gentoo Linux, use system-login
rather than password-auth. For OS X,
use login rather than
password-auth.
On Ubuntu and other Debian-based systems, use these file contents instead:
@include common-auth @include common-account @include common-session-noninteractive
Create a MySQL account with the same user name as the Unix login name and define it to authenticate using the PAM plugin:
CREATE USER 'antonio'@'localhost' IDENTIFIED WITH authentication_pam AS 'mysql'; GRANT ALL PRIVILEGES ON mydb.* TO 'antonio'@'localhost';
Connect to the MySQL server using the mysql command-line client. For example:
mysql --user=antonio --password=verysecret --enable-cleartext-plugin mydb
The server should permit the connection and the following query should return output as shown:
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
+-------------------+-------------------+--------------+
| USER() | CURRENT_USER() | @@proxy_user |
+-------------------+-------------------+--------------+
| antonio@localhost | antonio@localhost | NULL |
+-------------------+-------------------+--------------+
This demonstrates that antonio uses the
privileges granted to the antonio MySQL
account, and that no proxying has occurred.
This authentication scenario uses PAM only to check LDAP user login names and passwords. Every external user permitted to connect to MySQL Server should have a matching MySQL account that is defined to use external PAM authentication.
Verify that LDAP authentication in PAM permits you to log
in as antonio with password
verysecret.
Set up PAM to authenticate the mysql
service through LDAP by creating a file named
/etc/pam.d/mysql. The file contents
are system dependent, so check existing login-related
files in the /etc/pam.d directory to
see what they look like. On Linux, the
mysql file might look like this:
#%PAM-1.0 auth required pam_ldap.so account required pam_ldap.so
If PAM object files have a suffix different from
.so on your system, substitute the
correct suffix.
The PAM file might have a different format on some systems.
MySQL account creation and connecting to the server is the same as previously described in Section 7.1.3.3, “Unix Password Authentication without Proxy Users”.
This authentication scheme uses proxying and group mapping to map users who connect to the MySQL server through PAM onto MySQL accounts that define different sets of privileges. Users do not connect directly through the accounts that define the privileges. Instead, they connect through a default proxy user authenticating through PAM that uses a mapping scheme to map all the external logins to the few MySQL accounts holding the privileges. Any user who connects is mapped to one of the MySQL accounts and uses its privileges.
The procedure shown here uses Unix password authentication. To use LDAP instead, see the early steps of Section 7.1.3.4, “LDAP Authentication without Proxy Users”.
Verify that Unix authentication in PAM permits you to log
in as antonio with password
verysecret and that
antonio is a member of the
root or users group.
Set up PAM to authenticate the mysql
service. Put the following in
/etc/pam.d/mysql:
#%PAM-1.0 auth include password-auth account include password-auth
use system-login rather than
password-auth. For OS X, use
login rather than
password-auth.
The PAM file might have a different format on some systems. For example, on Ubuntu and other Debian-based systems, use these file contents instead:
@include common-auth @include common-account @include common-session-noninteractive
Create a default proxy user (''@'')
that maps the external PAM users to the proxied accounts.
It maps external users from the root
PAM group to the developer MySQL
account and the external users from the
users PAM group to the
data_entry MySQL account:
CREATE USER ''@'' IDENTIFIED WITH authentication_pam AS 'mysql, root=developer, users=data_entry';
The mapping list following the service name is required when you set up proxy users. Otherwise, the plugin cannot tell how to map the name of PAM groups to the proper proxied user name.
If your MySQL installation has anonymous users, they might conflict with the default proxy user. For more information about this problem, and ways of dealing with it, see Default Proxy User and Anonymous User Conflicts.
Create the proxied accounts that will be used to access the databases:
CREATE USER 'developer'@'localhost' IDENTIFIED BY 'very secret password'; GRANT ALL PRIVILEGES ON mydevdb.* TO 'developer'@'localhost'; CREATE USER 'data_entry'@'localhost' IDENTIFIED BY 'very secret password'; GRANT ALL PRIVILEGES ON mydb.* TO 'data_entry'@'localhost';
If you do not let anyone know the passwords for these
accounts, other users cannot use them to connect directly
to the MySQL server. Instead, it is expected that users
will authenticate using PAM and that they will use the
developer or
data_entry account by proxy based on
their PAM group.
Grant the PROXY privilege
to the proxy account for the proxied accounts:
GRANT PROXY ON 'developer'@'localhost' TO ''@''; GRANT PROXY ON 'data_entry'@'localhost' TO ''@'';
Connect to the MySQL server using the mysql command-line client. For example:
mysql --user=antonio --password=verysecret --enable-cleartext-plugin mydb
The server authenticates the connection using the
''@'' account. The privileges
antonio will have depends on what PAM
groups he is a member of. If antonio is a
member of the root PAM group, the PAM
plugin maps root to the
developer MySQL user name and returns
that name to the server. The server verifies that
''@'' has the
PROXY privilege for
developer and permits the connection.
the following query should return output as shown:
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
+-------------------+---------------------+--------------+
| USER() | CURRENT_USER() | @@proxy_user |
+-------------------+---------------------+--------------+
| antonio@localhost | developer@localhost | ''@'' |
+-------------------+---------------------+--------------+
This demonstrates that antonio uses the
privileges granted to the developer
MySQL account, and that proxying occurred through the
default proxy user account.
If antonio is not a member of the
root PAM group but is a member of the
users group, a similar process occurs,
but the plugin maps user group
membership to the data_entry MySQL user
name and returns that name to the server. In this case,
antonio uses the privileges of the
data_entry MySQL account:
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
+-------------------+----------------------+--------------+
| USER() | CURRENT_USER() | @@proxy_user |
+-------------------+----------------------+--------------+
| antonio@localhost | data_entry@localhost | ''@'' |
+-------------------+----------------------+--------------+
The PAM authentication plugin checks at initialization time
whether the AUTHENTICATION_PAM_LOG
environment value is set (the value does not matter). If so,
the plugin enables logging of diagnostic messages to the
standard output. These messages may be helpful for debugging
PAM-related problems that occur when the plugin performs
authentication.
Some messages include reference to PAM plugin source files and line numbers, which enables plugin actions to be tied more closely to the location in the code where they occur.
The following transcript demonstrates the kind of information produced by enabling logging. It resulted from a successful proxy authentication attempt.
entering auth_pam_server entering auth_pam_next_token auth_pam_next_token:reading at [cups,admin=writer,everyone=reader], sep=[,] auth_pam_next_token:state=PRESPACE, ptr=[cups,admin=writer,everyone=reader], out=[] auth_pam_next_token:state=IDENT, ptr=[cups,admin=writer,everyone=reader], out=[] auth_pam_next_token:state=AFTERSPACE, ptr=[,admin=writer,everyone=reader], out=[cups] auth_pam_next_token:state=DELIMITER, ptr=[,admin=writer,everyone=reader], out=[cups] auth_pam_next_token:state=DONE, ptr=[,admin=writer,everyone=reader], out=[cups] leaving auth_pam_next_token on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/parser.c:191 auth_pam_server:password 12345qq received auth_pam_server:pam_start rc=0 auth_pam_server:pam_set_item(PAM_RUSER,gkodinov) rc=0 auth_pam_server:pam_set_item(PAM_RHOST,localhost) rc=0 entering auth_pam_server_conv auth_pam_server_conv:PAM_PROMPT_ECHO_OFF [Password:] received leaving auth_pam_server_conv on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/authentication_pam.c:257 auth_pam_server:pam_authenticate rc=0 auth_pam_server:pam_acct_mgmt rc=0 auth_pam_server:pam_setcred(PAM_ESTABLISH_CRED) rc=0 auth_pam_server:pam_get_item rc=0 auth_pam_server:pam_setcred(PAM_DELETE_CRED) rc=0 entering auth_pam_map_groups entering auth_pam_walk_namevalue_list auth_pam_walk_namevalue_list:reading at: [admin=writer,everyone=reader] entering auth_pam_next_token auth_pam_next_token:reading at [admin=writer,everyone=reader], sep=[=] auth_pam_next_token:state=PRESPACE, ptr=[admin=writer,everyone=reader], out=[] auth_pam_next_token:state=IDENT, ptr=[admin=writer,everyone=reader], out=[] auth_pam_next_token:state=AFTERSPACE, ptr=[=writer,everyone=reader], out=[admin] auth_pam_next_token:state=DELIMITER, ptr=[=writer,everyone=reader], out=[admin] auth_pam_next_token:state=DONE, ptr=[=writer,everyone=reader], out=[admin] leaving auth_pam_next_token on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/parser.c:191 auth_pam_walk_namevalue_list:name=[admin] entering auth_pam_next_token auth_pam_next_token:reading at [writer,everyone=reader], sep=[,] auth_pam_next_token:state=PRESPACE, ptr=[writer,everyone=reader], out=[] auth_pam_next_token:state=IDENT, ptr=[writer,everyone=reader], out=[] auth_pam_next_token:state=AFTERSPACE, ptr=[,everyone=reader], out=[writer] auth_pam_next_token:state=DELIMITER, ptr=[,everyone=reader], out=[writer] auth_pam_next_token:state=DONE, ptr=[,everyone=reader], out=[writer] leaving auth_pam_next_token on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/parser.c:191 walk, &error_namevalue_list:value=[writer] entering auth_pam_map_group_to_user auth_pam_map_group_to_user:pam_user=gkodinov, name=admin, value=writer examining member root examining member gkodinov substitution was made to mysql user writer leaving auth_pam_map_group_to_user on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/authentication_pam.c:118 auth_pam_walk_namevalue_list:found mapping leaving auth_pam_walk_namevalue_list on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/parser.c:270 auth_pam_walk_namevalue_list returned 0 leaving auth_pam_map_groups on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/authentication_pam.c:171 auth_pam_server:authenticated_as=writer auth_pam_server: rc=0 leaving auth_pam_server on /Users/gkodinov/mysql/work/x-5.5.16-release-basket/release/plugin/pam-authentication-plugin/src/authentication_pam.c:429
The Windows authentication plugin is an extension included in MySQL Enterprise Edition, a commercial product. To learn more about commercial products, see http://www.mysql.com/products/.
As of MySQL 5.5.16, MySQL Enterprise Edition for Windows includes an authentication plugin that performs external authentication on Windows, enabling MySQL Server to use native Windows services to authenticate client connections. Users who have logged in to Windows can connect from MySQL client programs to the server based on the information in their environment without specifying an additional password.
The client and server exchange data packets in the authentication handshake. As a result of this exchange, the server creates a security context object that represents the identity of the client in the Windows OS. This identity includes the name of the client account. The Windows authentication plugin uses the identity of the client to check whether it is a given account or a member of a group. By default, negotiation uses Kerberos to authenticate, then NTLM if Kerberos is unavailable.
The Windows authentication plugin provides these capabilities:
External authentication: The plugin enables MySQL Server to accept connections from users defined outside the MySQL grant tables.
Proxy user support: The plugin can return to MySQL a user
name different from the client user. This means that the
plugin can return the MySQL user that defines the privileges
the external Windows-authenticated user should have. For
example, a Windows user named joe can
connect and have the privileges of the MySQL user named
developer.
The following table shows the plugin and library file names. The
file location must be the directory named by the
plugin_dir system variable. For
installation information, see
Section 7.1.4.1, “Installing the Windows Authentication Plugin”.
Table 7.4 MySQL Windows Authentication Plugin
| Server-side plugin name | authentication_windows |
| Client-side plugin name | authentication_windows_client |
| Library file name | authentication_windows.dll |
The library file includes only the server-side plugin. As of
MySQL 5.5.13, the client-side plugin is built into the
libmysqlclient client library.
The server-side Windows authentication plugin is included only in MySQL Enterprise Edition. It is not included in MySQL community distributions. The client-side plugin is included in all distributions, including community distributions. This permits clients from any 5.5.13 or higher distribution to connect to a server that has the server-side plugin loaded.
The Windows authentication plugin is supported on any version of Windows supported by MySQL 5.5 (see http://www.mysql.com/support/supportedplatforms/database.html). It requires MySQL Server 5.5.16 or higher.
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”. For proxy user information, see Section 5.7, “Proxy Users”.
This section describes how to install the Windows authentication plugin. For general information about installing plugins, see Installing and Uninstalling Plugins.
To be usable by the server, the plugin library file must be
located in the MySQL plugin directory (the directory named by
the plugin_dir system
variable). If necessary, set the value of
plugin_dir at server startup
to tell the server the plugin directory location.
To enable the plugin, start the server with the
--plugin-load option. For
example, put these lines in your my.ini
file:
[mysqld] plugin-load=authentication_windows.dll
To verify plugin installation, examine the
INFORMATION_SCHEMA.PLUGINS table
or use the SHOW PLUGINS
statement (see
Obtaining Server Plugin Information). For example:
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS->WHERE PLUGIN_NAME LIKE 'authentication%';+------------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +------------------------+---------------+ | authentication_windows | ACTIVE | +------------------------+---------------+
To associate a MySQL account with the Windows authentication
plugin, use the plugin name
authentication_windows in the
IDENTIFIED WITH clause of
CREATE USER or
GRANT statement that creates
the account.
The Windows authentication plugin supports the use of MySQL
accounts such that users who have logged in to Windows can
connect to the MySQL server without having to specify an
additional password. It is assumed that the server-side plugin
is enabled, as described previously, and that client programs
are recent enough to include the client-side plugin built into
libmysqlclient (MySQL 5.5.13 or higher).
Once the DBA has enabled the server-side plugin and set up
accounts to use it, clients can connect using those accounts
with no other setup required on their part.
To refer to the Windows authentication plugin in the
IDENTIFIED WITH clause of a
CREATE USER or
GRANT statement, use the name
authentication_windows. Suppose that the
Windows users Rafal and
Tasha should be permitted to connect to
MySQL, as well as any users in the
Administrators or Power
Users group. To set this up, create a MySQL account
named sql_admin that uses the Windows
plugin for authentication:
CREATE USER sql_admin IDENTIFIED WITH authentication_windows AS 'Rafal, Tasha, Administrators, "Power Users"';
The plugin name is authentication_windows.
The string following the AS keyword is the
authentication string. It specifies that the Windows users
named Rafal or Tasha are
permitted to authenticate to the server as the MySQL user
sql_admin, as are any Windows users in the
Administrators or Power
Users group. The latter group name contains a space,
so it must be quoted with double quote characters.
After you create the sql_admin account, a
user who has logged in to Windows can attempt to connect to
the server using that account:
C:\> mysql --user=sql_admin
No password is required here. The
authentication_windows plugin uses the
Windows security API to check which Windows user is
connecting. If that user is named Rafal or
Tasha, or is in the
Administrators or Power
Users group, the server grants access and the client
is authenticated as sql_admin and has
whatever privileges are granted to the
sql_admin account. Otherwise, the server
denies access.
Authentication string syntax for the Windows authentication plugin follows these rules:
The string consists of one or more user mappings separated by commas.
Each user mapping associates a Windows user or group name with a MySQL user name:
win_user_or_group_name=mysql_user_namewin_user_or_group_name
For the latter syntax, with no
mysql_user_name value given,
the implicit value is the MySQL user created by the
CREATE USER statement.
Thus, these statements are equivalent:
CREATE USER sql_admin
IDENTIFIED WITH authentication_windows
AS 'Rafal, Tasha, Administrators, "Power Users"';
CREATE USER sql_admin
IDENTIFIED WITH authentication_windows
AS 'Rafal=sql_admin, Tasha=sql_admin, Administrators=sql_admin,
"Power Users"=sql_admin';
Each backslash ('\') in a value must be
doubled because backslash is the escape character in MySQL
strings.
Leading and trailing spaces not inside double quotation marks are ignored.
Unquoted win_user_or_group_name
and mysql_user_name values can
contain anything except equal sign, comma, or space.
If a win_user_or_group_name and
or mysql_user_name value is
quoted with double quotation marks, everything between the
quotation marks is part of the value. This is necessary,
for example, if the name contains space characters. All
characters within double quotes are legal except double
quotation mark and backslash. To include either character,
escape it with a backslash.
win_user_or_group_name values
use conventional syntax for Windows principals, either
local or in a domain. Examples (note the doubling of
backslashes):
domain\\user .\\user domain\\group .\\group BUILTIN\\WellKnownGroup
When invoked by the server to authenticate a client, the
plugin scans the authentication string left to right for a
user or group match to the Windows user. If there is a match,
the plugin returns the corresponding
mysql_user_name to the MySQL
server. If there is no match, authentication fails.
A user name match takes preference over a group name match.
Suppose that the Windows user named
win_user is a member of
win_group and the authentication string
looks like this:
'win_group = sql_user1, win_user = sql_user2'
When win_user connects to the MySQL server,
there is a match both to win_group and to
win_user. The plugin authenticates the user
as sql_user2 because the more-specific user
match takes precedence over the group match, even though the
group is listed first in the authentication string.
Windows authentication always works for connections from the same computer on which the server is running. For cross-computer connections, both computers must be registered with Windows Active Directory. If they are in the same Windows domain, it is unnecessary to specify a domain name. It is also possible to permit connections from a different domain, as in this example:
CREATE USER sql_accounting IDENTIFIED WITH authentication_windows AS 'SomeDomain\\Accounting';
Here SomeDomain is the name of the other
domain. The backslash character is doubled because it is the
MySQL escape character within strings.
MySQL supports the concept of proxy users whereby a client can connect and authenticate to the MySQL server using one account but while connected has the privileges of another account (see Section 5.7, “Proxy Users”). Suppose that you want Windows users to connect using a single user name but be mapped based on their Windows user and group names onto specific MySQL accounts as follows:
The local_user and
MyDomain\domain_user local and domain
Windows users should map to the
local_wlad MySQL account.
Users in the MyDomain\Developers domain
group should map to the local_dev MySQL
account.
Local machine administrators should map to the
local_admin MySQL account.
To set this up, create a proxy account for Windows users to
connect to, and configure this account so that users and
groups map to the appropriate MySQL accounts
(local_wlad, local_dev,
local_admin). In addition, grant the MySQL
accounts the privileges appropriate to the operations they
need to perform. The following instructions use
win_proxy as the proxy account, and
local_wlad, local_dev,
and local_admin as the proxied accounts.
Create the proxy MySQL account:
CREATE USER win_proxy
IDENTIFIED WITH authentication_windows
AS 'local_user = local_wlad,
MyDomain\\domain_user = local_wlad,
MyDomain\\Developers = local_dev,
BUILTIN\\Administrators = local_admin';
For proxying to work, the proxied accounts must exist, so create them:
CREATE USER local_wlad IDENTIFIED BY 'wlad_pass'; CREATE USER local_dev IDENTIFIED BY 'dev_pass'; CREATE USER local_admin IDENTIFIED BY 'admin_pass';
If you do not let anyone know the passwords for these accounts, other users cannot use them to connect directly to the MySQL server.
You should also issue GRANT
statements (not shown) that grant each proxied account the
privileges it needs.
The proxy account must have the
PROXY privilege for each of
the proxied accounts:
GRANT PROXY ON local_wlad TO win_proxy; GRANT PROXY ON local_dev TO win_proxy; GRANT PROXY ON local_admin TO win_proxy;
Now the Windows users local_user and
MyDomain\domain_user can connect to the
MySQL server as win_proxy and when
authenticated have the privileges of the account given in the
authentication string—in this case,
local_wlad. A user in the
MyDomain\Developers group who connects as
win_proxy has the privileges of the
local_dev account. A user in the
BUILTIN\Administrators group has the
privileges of the local_admin account.
To configure authentication so that all Windows users who do
not have their own MySQL account go through a proxy account,
substitute the default proxy user (''@'')
for win_proxy in the preceding
instructions. For information about the default proxy user,
see Section 5.7, “Proxy Users”.
If your MySQL installation has anonymous users, they might conflict with the default proxy user. For more information about this problem, and ways of dealing with it, see Default Proxy User and Anonymous User Conflicts.
To use the Windows authentication plugin with Connector/Net connection strings in Connection/Net 6.4.4 and higher, see Using the Windows Native Authentication Plugin.
Additional control over the Windows authentication plugin is
provided by the
authentication_windows_use_principal_name
and
authentication_windows_log_level
system variables. See
Server System Variables.
As of MySQL 5.5.10, a client-side authentication plugin is available that sends the password to the server without hashing or encryption. This plugin is built into the MySQL client library.
The following table shows the plugin name.
Table 7.5 MySQL Cleartext Authentication Plugin
| Server-side plugin name | None, see discussion |
| Client-side plugin name | mysql_clear_password |
| Library file name | None (plugin is built in) |
With native MySQL authentication, the client performs one-way hashing on the password before sending it to the server. This enables the client to avoid sending the password in clear text. See Section 2.2.4, “Password Hashing in MySQL”. However, because the hash algorithm is one way, the original password cannot be recovered on the server side.
One-way hashing cannot be done for authentication schemes that
require the server to receive the password as entered on the
client side. In such cases, the
mysql_clear_password client-side plugin can
be used to send the password to the server in clear text. There
is no corresponding server-side plugin. Rather, the client-side
plugin can be used by any server-side plugin that needs a clear
text password. (The PAM authentication plugin is one such; see
Section 7.1.3, “The PAM Authentication Plugin”.)
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”.
Sending passwords in clear text may be a security problem in some configurations. To avoid problems if there is any possibility that the password would be intercepted, clients should connect to MySQL Server using a method that protects the password. Possibilities include SSL (see Chapter 6, Using Secure Connections), IPsec, or a private network.
As of MySQL 5.5.27, to make inadvertent use of this plugin less likely, it is required that clients explicitly enable it. This can be done several ways:
Set the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN
environment variable to a value that begins with
1, Y, or
y. This enables the plugin for all client
connections.
The mysql, mysqladmin,
and mysqlslap client programs support an
--enable-cleartext-plugin option that
enables the plugin on a per-invocation basis.
The mysql_options() C API
function supports a
MYSQL_ENABLE_CLEARTEXT_PLUGIN option that
enables the plugin on a per-connection basis. Also, any
program that uses libmysqlclient and
reads option files can enable the plugin by including an
enable-cleartext-plugin option in an
option group read by the client library.
As of MySQL 5.5.10, a server-side authentication plugin is available that authenticates clients that connect from the local host through the Unix socket file. This plugin works only on Linux systems.
The source code for this plugin can be examined as a relatively simple example demonstrating how to write a loadable authentication plugin.
The following table shows the plugin and library file names. The
file name suffix might differ on your system. The file location
is the directory named by the
plugin_dir system variable. For
installation information, see
Section 5.6, “Pluggable Authentication”.
Table 7.6 MySQL Socket Peer-Credential Authentication Plugin
| Server-side plugin name | auth_socket |
| Client-side plugin name | None, see discussion |
| Library file name | auth_socket.so |
The auth_socket authentication plugin
authenticates clients that connect from the local host through
the Unix socket file. The plugin uses the
SO_PEERCRED socket option to obtain
information about the user running the client program. Thus, the
plugin can be built only on systems that support the
SO_PEERCRED option, such as Linux.
The plugin checks whether the user name matches the MySQL user name specified by the client program to the server, and permits the connection only if the names match.
Suppose that a MySQL account is created for a user named
valerie who is to be authenticated by the
auth_socket plugin for connections from the
local host through the socket file:
CREATE USER 'valerie'@'localhost' IDENTIFIED WITH auth_socket;
If a user on the local host with a login name of
stefanie invokes mysql
with the option --user=valerie to connect
through the socket file, the server uses
auth_socket to authenticate the client. The
plugin determines that the --user option value
(valerie) differs from the client user's name
(stephanie) and refuses the connection. If a
user named valerie tries the same thing, the
plugin finds that the user name and the MySQL user name are both
valerie and permits the connection. However,
the plugin refuses the connection even for
valerie if the connection is made using a
different protocol, such as TCP/IP.
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”.
MySQL includes a test plugin that authenticates using MySQL native authentication, but is a loadable plugin (not built in) and must be installed prior to use. It can authenticate against either normal or older (shorter) password hash values.
This plugin is intended for testing and development purposes, and not for use in production environments. The test plugin source code is separate from the server source, unlike the built-in native plugin, so it can be examined as a relatively simple example demonstrating how to write a loadable authentication plugin.
The following table shows the plugin and library file names. The
file name suffix might differ on your system. The file location
is the directory named by the
plugin_dir system variable. For
installation information, see
Section 5.6, “Pluggable Authentication”.
Table 7.7 MySQL Test Authentication Plugin
| Server-side plugin name | test_plugin_server |
| Client-side plugin name | auth_test_plugin |
| Library file name | auth_test_plugin.so |
Because the test plugin authenticates the same way as native
MySQL authentication, provide the usual
--user and
--password options that you
normally use for accounts that use native authentication when
you connect to the server. For example:
shell> mysql --user=your_name --password=your_pass
For general information about pluggable authentication in MySQL, see Section 5.6, “Pluggable Authentication”.
MySQL Enterprise Audit is an extension included in MySQL Enterprise Edition, a commercial product. To learn more about commercial products, see http://www.mysql.com/products/.
As of MySQL 5.5.28, MySQL Enterprise Edition includes MySQL Enterprise Audit, implemented using a
server plugin named audit_log. MySQL Enterprise Audit uses
the open MySQL Audit API to enable standard, policy-based
monitoring and logging of connection and query activity executed
on specific MySQL servers. Designed to meet the Oracle audit
specification, MySQL Enterprise Audit provides an out of box, easy to use
auditing and compliance solution for applications that are
governed by both internal and external regulatory guidelines.
When installed, the audit plugin enables MySQL Server to produce a log file containing an audit record of server activity. The log contents include when clients connect and disconnect, and what actions they perform while connected, such as which databases and tables they access.
After you install the plugin (see
Section 7.2.1, “Installing MySQL Enterprise Audit”), it writes an audit log
file. By default, the file is named audit.log
in the server data directory. To change the name of the file, set
the audit_log_file system
variable at server startup.
Audit log file contents are not encrypted. See Section 7.2.2, “MySQL Enterprise Audit Security Considerations”.
The audit log file is written in XML, with auditable events
encoded as <AUDIT_RECORD> elements. To
select the file format, set the
audit_log_format system variable
at server startup. For details on file format and contents, see
Section 7.2.3, “The Audit Log File”.
To control what information audit_log writes to
its log file, set the
audit_log_policy system variable.
By default, this variable is set to ALL (write
all auditable events), but also permits values of
LOGINS or QUERIES to log
only login or query events, or NONE to disable
logging.
For more information about controlling how logging occurs, see Section 7.2.4, “Audit Log Logging Control”. For descriptions of the parameters used to configure the audit log plugin, see Section 7.2.7, “Audit Log Options and System Variables”.
If the audit_log plugin is enabled, the
Performance Schema (see MySQL Performance Schema) has
instrumentation for the audit log plugin. To identify the relevant
instruments, use this query:
SELECT NAME FROM performance_schema.setup_instruments WHERE NAME LIKE '%/alog/%';
Several changes were made to the audit log plugin in MySQL 5.5.34 for better compatibility with Oracle Audit Vault.
MySQL 5.7 changed audit log file output to a new format. This
format has been backported to MySQL 5.5 and it is
possible to select either the old or new format using the
audit_log_format system variable,
which has permitted values of OLD and
NEW (default OLD). The two
formats differ as follows:
Information within <AUDIT_RECORD>
elements written in the old format using attributes is written
in the new format using subelements.
The new format includes more information in
<AUDIT_RECORD> elements. Every
element includes a RECORD_ID value
providing a unique identifier. The
TIMESTAMP value includes time zone
information. Query records include HOST,
IP, OS_LOGIN, and
USER information, as well as
COMMAND_CLASS and
STATUS_CODE values.
Example of old <AUDIT_RECORD> format:
<AUDIT_RECORD TIMESTAMP="2013-09-15T15:27:27" NAME="Query" CONNECTION_ID="3" STATUS="0" SQLTEXT="SELECT 1" />
Example of new <AUDIT_RECORD> format:
<AUDIT_RECORD> <TIMESTAMP>2013-09-15T15:27:27 UTC</TIMESTAMP> <RECORD_ID>3998_2013-09-15T15:27:27</RECORD_ID> <NAME>Query</NAME> <CONNECTION_ID>3</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>select</COMMAND_CLASS> <SQLTEXT>SELECT 1</SQLTEXT> </AUDIT_RECORD>
When the audit log plugin rotates the audit log file, it uses a
different file name format. For a log file named
audit.log, the plugin previously renamed the
file to
audit.log..
The plugin now renames the file to
TIMESTAMPaudit.log.
to indicate that it is an XML file.
TIMESTAMP.xml
If you change the value of
audit_log_format, use this
procedure to avoid writing log entries in one format to an
existing log file that contains entries in a different format:
Stop the server.
Rename the current audit log file manually.
Restart the server with the new value of
audit_log_format. The audit
log plugin will create a new log file, which will contain log
entries in the selected format.
The API for writing audit plugins has also changed. The
mysql_event_general structure has new members
to represent client host name and IP address, command class, and
external user. For more information, see
Writing Audit Plugins.
This section describes how to install MySQL Enterprise Audit, which is
implemented using the audit_log plugin. For
general information about installing plugins, see
Installing and Uninstalling Plugins.
If installed, the audit_log plugin involves
some minimal overhead even when disabled. To avoid this
overhead, do not install MySQL Enterprise Audit unless you plan to use it.
To be usable by the server, the plugin library file must be
located in the MySQL plugin directory (the directory named by
the plugin_dir system
variable). If necessary, set the value of
plugin_dir at server startup to
tell the server the plugin directory location.
The plugin library file base name is
audit_log. The file name suffix differs per
platform (for example, .so for Unix and
Unix-like systems, .dll for Windows).
To load the plugin at server startup, use the
--plugin-load option to name the
library file that contains the plugin. With this plugin-loading
method, the option must be given each time the server starts.
For example, put the following lines in your
my.cnf file (adjust the
.so suffix for your platform as necessary):
[mysqld] plugin-load=audit_log.so
Alternatively, to register the plugin at runtime, use this statement (adjust the suffix as necessary):
INSTALL PLUGIN audit_log SONAME 'audit_log.so';
INSTALL PLUGIN loads the plugin,
and also registers it in the mysql.plugins
table to cause the plugin to be loaded for each subsequent
normal server startup.
To verify plugin installation, examine the
INFORMATION_SCHEMA.PLUGINS table or
use the SHOW PLUGINS statement
(see Obtaining Server Plugin Information). For
example:
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS->WHERE PLUGIN_NAME LIKE 'audit%';+-------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +-------------+---------------+ | audit_log | ACTIVE | +-------------+---------------+
If the plugin has been previously registered with
INSTALL PLUGIN or is loaded with
--plugin-load, you can use the
--audit-log option at server startup to control
plugin activation. For example, to load the plugin at startup
and prevent it from being removed at runtime, use these options:
[mysqld] plugin-load=audit_log.so audit-log=FORCE_PLUS_PERMANENT
If it is desired to prevent the server from running without the
audit plugin, use --audit-log
with a value of FORCE or
FORCE_PLUS_PERMANENT to force server startup
to fail if the plugin does not initialize successfully.
For additional information about the parameters used to
configure operation of the audit_log plugin,
see Section 7.2.7, “Audit Log Options and System Variables”.
Audit log file contents are not encrypted. See Section 7.2.2, “MySQL Enterprise Audit Security Considerations”.
Contents of the audit log file produced by the
audit_log plugin are not encrypted and may
contain sensitive information, such as the text of SQL
statements. For security reasons, this file should be written to
a directory accessible only to the MySQL server and users with a
legitimate reason to view the log. The default file is
audit.log in the data directory. This can
be changed by setting the
audit_log_file system variable
at server startup.
Audit log file contents are not encrypted. See Section 7.2.2, “MySQL Enterprise Audit Security Considerations”.
The audit log file is written as XML, using UTF-8 (up to 4 bytes
per character). The root element is
<AUDIT>. The closing
</AUDIT> tag of the root element is
written when the audit log plugin terminates, so the tag is not
present in the file while the plugin is active.
The root element contains
<AUDIT_RECORD> elements. Each
<AUDIT_RECORD> element has an empty
body; all audit record fields are represented by element
attributes.
MySQL 5.7 changed audit log file output to a new format that has
better compatibility with Oracle Audit Vault. This new format
was backported to MySQL 5.5 as of MySQL 5.5.34 and
it is possible to select either the old or new format using the
audit_log_format system
variable, which has permitted values of OLD
and NEW (default OLD).
If you change the value of
audit_log_format, use this
procedure to avoid writing log entries in one format to an
existing log file that contains entries in a different format:
Stop the server.
Rename the current audit log file manually.
Restart the server with the new value of
audit_log_format. The audit
log plugin will create a new log file, which will contain
log entries in the selected format.
Here is a sample log file in the default (old) format, reformatted slightly for readability:
<?xml version="1.0" encoding="utf-8"?>
<AUDIT>
<AUDIT_RECORD
TIMESTAMP="2012-08-02T14:52:12"
NAME="Audit"
SERVER_ID="1"
VERSION="1"
STARTUP_OPTIONS="--port=3306"
OS_VERSION="i686-Linux"
MYSQL_VERSION="5.5.28-debug-log"/>
<AUDIT_RECORD
TIMESTAMP="2012-08-02T14:52:41"
NAME="Connect"
CONNECTION_ID="1"
STATUS="0"
USER="root"
PRIV_USER="root"
OS_LOGIN=""
PROXY_USER=""
HOST="localhost"
IP="127.0.0.1"
DB=""/>
<AUDIT_RECORD
TIMESTAMP="2012-08-02T14:53:45"
NAME="Query"
CONNECTION_ID="1"
STATUS="0"
SQLTEXT="INSERT INTO t1 () VALUES()"/>
<AUDIT_RECORD
TIMESTAMP="2012-08-02T14:53:51"
NAME="Quit"
CONNECTION_ID="1"
STATUS="0"/>
<AUDIT_RECORD
TIMESTAMP="2012-08-06T14:21:03"
NAME="NoAudit"
SERVER_ID="1"/>
</AUDIT>
Attributes of <AUDIT_RECORD> elements
have these characteristics:
Some attributes appear in every element, but most are optional and do not necessarily appear in every element.
Order of attributes within an element is not guaranteed.
Attribute values are not fixed length. Long values may be truncated as indicated in the attribute descriptions given later.
The <, >,
", and &
characters are encoded as <,
>, ",
and &, respectively. NUL bytes
(U+00) are encoded as the ? character.
Characters not valid as XML characters are encoded using numeric character references. Valid XML characters are:
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
Every <AUDIT_RECORD> element contains
a set of mandatory elements. Other optional elements may
appear, depending on the audit record type.
The following elements are mandatory in every
<AUDIT_RECORD> element:
<NAME>
A string representing the type of instruction that generated the audit event, such as a command that the server received from a client.
Example:
<NAME>Query</NAME>
Some common <NAME> values:
Audit When auditing starts, which may be server startup time Connect When a client connects, also known as logging in Query An SQL statement (executed directly) Prepare Preparation of an SQL statement; usually followed by Execute Execute Execution of an SQL statement; usually follows Prepare Shutdown Server shutdown Quit When a client disconnects NoAudit Auditing has been turned off
The possible values are Audit,
Binlog Dump, Change
user, Close stmt,
Connect Out,
Connect, Create DB,
Daemon, Debug,
Delayed insert, Drop
DB, Execute,
Fetch, Field List,
Init DB, Kill,
Long Data, NoAudit,
Ping, Prepare,
Processlist, Query,
Quit, Refresh,
Register Slave, Reset
stmt, Set option,
Shutdown, Sleep,
Statistics, Table
Dump, Time.
With the exception of Audit and
NoAudit, these values correspond to the
COM_
command values listed in the
xxxmysql_com.h header file. For example,
Create DB and
Shutdown correspond to
COM_CREATE_DB and
COM_SHUTDOWN, respectively.
<RECORD_ID>
A unique identifier for the audit record. The value is
composed from a sequence number and timestamp, in the
format
.
The sequence number is initialized to the size of the
audit log file at the time the audit log plugin opens it
and increments by 1 for each record logged. The timestamp
is a UTC value in
SEQ_TIMESTAMP
format indicating the time when the audit log plugin
opened the file.
yyyy-mm-ddThh:mm:ss
Example:
<RECORD_ID>28743_2013-09-18T21:03:24</RECORD_ID>
<TIMESTAMP>
The date and time that the audit event was generated. For
example, the event corresponding to execution of an SQL
statement received from a client has a
<TIMESTAMP> value occurring after
the statement finishes, not when it is received. The value
has the format
(with yyyy-mm-ddThh:mm:ss
UTCT, no decimals).
The format includes a time zone specifier at the end. The
time zone is always UTC.
Example:
<TIMESTAMP>2013-09-17T15:03:49 UTC</TIMESTAMP>
The following elements are optional in
<AUDIT_RECORD> elements. Many of them
occur only with specific <NAME>
values.
<COMMAND_CLASS>
A string that indicates the type of action performed.
Example:
<COMMAND_CLASS>drop_table</COMMAND_CLASS>
The values come from the
com_status_vars array in the
sql/mysqld.cc file in a MySQL source
distribution. They correspond to the status variables
displayed by this statement:
SHOW STATUS LIKE 'Com%';
<CONNECTION_ID>
An unsigned integer representing the client connection
identifier. This is the same as the
CONNECTION_ID() function
value within the session.
Example:
<CONNECTION_ID>127</CONNECTION_ID>
<DB>
A string representing the default database name. This
element appears only if the
<NAME> value is
Connect or Change
user.
<HOST>
A string representing the client host name. This element
appears only if the <NAME> value
is Connect, Change
user, or Query.
Example:
<HOST>localhost</HOST>
<IP>
A string representing the client IP address. This element
appears only if the <NAME> value
is Connect, Change
user, or Query.
Example:
<IP>127.0.0.1</IP>
<MYSQL_VERSION>
A string representing the MySQL server version. This is
the same as the value of the
VERSION() function or
version system variable.
This element appears only if the
<NAME> value is
Audit.
Example:
<MYSQL_VERSION>5.7.1-m11-log</MYSQL_VERSION>
<OS_LOGIN>
A string representing the external user (empty if none).
The value may differ from the
<USER> value, for example, if the
server authenticates the client using an external
authentication method. This element appears only if the
<NAME> value is
Connect, Change
user, or Query.
<OS_VERSION>
A string representing the operating system on which the
server was built or is running. This element appears only
if the <NAME> value is
Audit.
Example:
<OS_VERSION>x86_64-Linux</OS_VERSION>
<PRIV_USER>
A string representing the user that the server
authenticated the client as. This is the user name that
the server uses for privilege checking, and may differ
from the <USER> value. This
element appears only if the
<NAME> value is
Connect or Change
user.
<PROXY_USER>
A string representing the proxy user. The value is empty
if user proxying is not in effect. This element appears
only if the <NAME> value is
Connect or Change
user.
<SERVER_ID>
An unsigned integer representing the server ID. This is
the same as the value of the
server_id system
variable. This element appears only if the
<NAME> value is
Audit or NoAudit.
Example:
<SERVER_ID>1</SERVER_ID>
<SQLTEXT>
A string representing the text of an SQL statement. The
value can be empty. Long values may be truncated. This
element appears only if the
<NAME> value is
Query or Execute.
The string, like the audit log file itself, is written using UTF-8 (up to 4 bytes per character), so the value may be the result of conversion. For example, the original statement might have been received from the client as an SJIS string.
Example:
<SQLTEXT>DELETE FROM t1</SQLTEXT>
<STARTUP_OPTIONS>
A string representing the options that were given on the
command line or in option files when the MySQL server was
started. This element appears only if the
<NAME> value is
Audit.
Example:
<STARTUP_OPTIONS>/usr/local/mysql/bin/mysqld --port=3306 --log-output=FILE</STARTUP_OPTIONS>
<STATUS>
An unsigned integer representing the command status: 0 for
success, nonzero if an error occurred. This is the same as
the value of the
mysql_errno() C API
function.
The audit log does not contain the SQLSTATE value or error message. To see the associations between error codes, SQLSTATE values, and messages, see Server Error Codes and Messages.
Warnings are not logged.
See the description for
<STATUS_CODE> for information
about how it differs from
<STATUS>.
Example:
<STATUS>1051</STATUS>
<STATUS_CODE>
An unsigned integer representing the command status: 0 for success, 1 if an error occurred.
The STATUS_CODE value differs from the
STATUS value:
STATUS_CODE is 0 for success and 1 for
error, which is compatible with the EZ_collector consumer
for Audit Vault. STATUS is the value of
the mysql_errno() C API
function. This is 0 for success and nonzero for error, and
thus is not necessarily 1 for error.
Example:
<STATUS_CODE>0</STATUS_CODE>
<USER>
A string representing the user name sent by the client.
This may differ from the
<PRIV_USER> value. This element
appears only if the <NAME> value
is Connect, Change
user, or Query.
Example:
<USER>root[root] @ localhost [127.0.0.1]</USER>
<VERSION>
An unsigned integer representing the version of the audit
log file format. This element appears only if the
<NAME> value is
Audit.
Example:
<VERSION>1</VERSION>
Every <AUDIT_RECORD> element contains
a set of mandatory attributes. Other optional attributes may
appear depending on the audit record type.
The following attributes are mandatory in every
<AUDIT_RECORD> element:
NAME
A string representing the type of instruction that generated the audit event, such as a command that the server received from a client.
Example: NAME="Query"
Some common NAME values:
"Audit" When auditing starts, which may be server startup time "Connect" When a client connects, also known as logging in "Query" An SQL statement (executed directly) "Prepare" Preparation of an SQL statement; usually followed by Execute "Execute" Execution of an SQL statement; usually follows Prepare "Shutdown" Server shutdown "Quit" When a client disconnects "NoAudit" Auditing has been turned off
The possible values are "Audit",
"Binlog Dump", "Change
user", "Close stmt",
"Connect Out",
"Connect", "Create
DB", "Daemon",
"Debug", "Delayed
insert", "Drop DB",
"Execute", "Fetch",
"Field List", "Init
DB", "Kill", "Long
Data", "NoAudit",
"Ping", "Prepare",
"Processlist",
"Query", "Quit",
"Refresh", "Register
Slave", "Reset stmt",
"Set option",
"Shutdown", "Sleep",
"Statistics", "Table
Dump", "Time".
With the exception of "Audit" and
"NoAudit", these values correspond to
the COM_
command values listed in the
xxxmysql_com.h header file. For example,
"Create DB" and
"Shutdown" correspond to
COM_CREATE_DB and
COM_SHUTDOWN, respectively.
TIMESTAMP
The date and time that the audit event was generated. For
example, the event corresponding to execution of an SQL
statement received from a client has a
TIMESTAMP value occurring after the
statement finishes, not when it is received. The value is
UTC, in the format
(with yyyy-mm-ddThh:mm:ssT, no decimals).
Example:
TIMESTAMP="2012-08-09T12:55:16"
The following attributes are optional in
<AUDIT_RECORD> elements. Many of them
occur only for elements with specific values of the
NAME attribute.
CONNECTION_ID
An unsigned integer representing the client connection
identifier. This is the same as the
CONNECTION_ID() function
value within the session.
Example: CONNECTION_ID="127"
DB
A string representing the default database name. This
attribute appears only if the NAME
value is "Connect" or "Change
user".
HOST
A string representing the client host name. This attribute
appears only if the NAME value is
"Connect" or "Change
user".
Example: HOST="localhost"
IP
A string representing the client IP address. This
attribute appears only if the NAME
value is "Connect" or "Change
user".
Example: IP="127.0.0.1"
MYSQL_VERSION
A string representing the MySQL server version. This is
the same as the value of the
VERSION() function or
version system variable.
This attribute appears only if the NAME
value is "Audit".
Example: MYSQL_VERSION="5.5.31-log"
OS_LOGIN
A string representing the external user (empty if none).
The value may differ from USER, for
example, if the server authenticates the client using an
external authentication method. This attribute appears
only if the NAME value is
"Connect" or "Change
user".
OS_VERSION
A string representing the operating system on which the
server was built or is running. This attribute appears
only if the NAME value is
"Audit".
Example: OS_VERSION="x86_64-Linux"
PRIV_USER
A string representing the user that the server
authenticated the client as. This is the user name that
the server uses for privilege checking, and may be
different from the USER value. This
attribute appears only if the NAME
value is "Connect" or "Change
user".
PROXY_USER
A string representing the proxy user. The value is empty
if user proxying is not in effect. This attribute appears
only if the NAME value is
"Connect" or "Change
user".
SERVER_ID
An unsigned integer representing the server ID. This is
the same as the value of the
server_id system
variable. This attribute appears only if the
NAME value is
"Audit" or
"NoAudit".
Example: SERVER_ID="1"
SQLTEXT
A string representing the text of an SQL statement. The
value can be empty. Long values may be truncated. This
attribute appears only if the NAME
value is "Query" or
"Execute".
The string, like the audit log file itself, is written using UTF-8 (up to 4 bytes per character), so the value may be the result of conversion. For example, the original statement might have been received from the client as an SJIS string.
Example: SQLTEXT="DELETE FROM t1"
STARTUP_OPTIONS
A string representing the options that were given on the
command line or in option files when the MySQL server was
started. This attribute appears only if the
NAME value is
"Audit".
Example: STARTUP_OPTIONS="--port=3306
--log-output=FILE"
STATUS
An unsigned integer representing the command status: 0 for
success, nonzero if an error occurred. This is the same as
the value of the
mysql_errno() C API
function.
The audit log does not contain the SQLSTATE value or error message. To see the associations between error codes, SQLSTATE values, and messages, see Server Error Codes and Messages.
Warnings are not logged.
Example: STATUS="1051"
USER
A string representing the user name sent by the client.
This may be different from the
PRIV_USER value. This attribute appears
only if the NAME value is
"Connect" or "Change
user".
VERSION
An unsigned integer representing the version of the audit
log file format. This attribute appears only if the
NAME value is
"Audit".
Example: VERSION="1"
This section describes how the audit_log
plugin performs logging and the system variables that control
how logging occurs. It assumes familiarity with the log file
format described in Section 7.2.3, “The Audit Log File”.
When the audit log plugin opens its log file, it checks whether
the XML declaration and opening <AUDIT>
root element tag must be written and writes them if so. When the
audit log plugin terminates, it writes a closing
</AUDIT> tag to the file.
If the log file exists at open time, the plugin checks whether
the file ends with an </AUDIT> tag and
truncates it if so before writing any
<AUDIT_RECORD> elements. If the log
file exists but does not end with
</AUDIT> or the
</AUDIT> tag cannot be truncated, the
plugin considers the file malformed and fails to initialize.
This can occur if the server crashes or is killed with the audit
log plugin running. No logging occurs until the problem is
rectified. Check the error log for diagnostic information:
[ERROR] Plugin 'audit_log' init function returned error.
To deal with this problem, either remove or rename the malformed log file and restart the server.
The MySQL server calls the audit log plugin to write an
<AUDIT_RECORD> element whenever an
auditable event occurs, such as when it completes execution of
an SQL statement received from a client. Typically the first
<AUDIT_RECORD> element written after
server startup has the server description and startup options.
Elements following that one represent events such as client
connect and disconnect events, executed SQL statements, and so
forth. Only top-level statements are logged, not statements
within stored programs such as triggers or stored procedures.
Contents of files referenced by statements such as
LOAD DATA
INFILE are not logged.
To permit control over how logging occurs, the
audit_log plugin provides several system
variables, described following. For more information, see
Section 7.2.7, “Audit Log Options and System Variables”.
To control the audit log file name, set the
audit_log_file system
variable at server startup. By default, the name is
audit.log in the server data directory.
For security reasons, the audit log file should be written to
a directory accessible only to the MySQL server and users with
a legitimate reason to view the log.
The audit log plugin can use any of several strategies for log
writes. To specify a strategy, set the
audit_log_strategy system
variable at server startup. By default, the strategy value is
ASYNCHRONOUS and the plugin logs
asynchronously to a buffer, waiting if the buffer is full.
It's possible to tell the plugin not to wait
(PERFORMANCE) or to log synchronously,
either using file system caching
(SEMISYNCHRONOUS) or forcing output with a
sync() call after each write request
(SYNCHRONOUS).
Asynchronous logging strategy has these characteristics:
Minimal impact on server performance and scalability.
Blocking of threads that generate audit events for the shortest possible time; that is, time to allocate the buffer plus time to copy the event to the buffer.
Output goes to the buffer. A separate thread handles writes from the buffer to the log file.
A disadvantage of PERFORMANCE strategy is
that it drops events when the buffer is full. For a heavily
loaded server, it is more likely that the audit log will be
missing events.
With asynchronous logging, the integrity of the log file may
be compromised if a problem occurs during a write to the file
or if the plugin does not shut down cleanly (for example, in
the event that the server host crashes). To reduce this risk,
set audit_log_strategy to use
synchronous logging. Regardless of strategy, logging occurs on
a best-effort basis, with no guarantee of consistency.
The audit log plugin provides several system variables that enable you to manage the space used by its log files:
audit_log_buffer_size:
Set this variable at server startup to set the size of the
buffer for asynchronous logging. 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_rotate_on_size,
audit_log_flush: These
variables permit audit log file rotation and flushing. The
audit log file has the potential to grow very large and
consume a lot of disk space. To manage the space used,
either enable automatic log rotation, or manually rename
the audit file and flush the log to open a new file. The
renamed file can be removed or backed up as desired.
By default,
audit_log_rotate_on_size=0
and there is no log rotation. In this case, the audit log
plugin closes and reopens the log file when the
audit_log_flush value
changes from disabled to enabled. Log file renaming must
be done externally to the server. Suppose that you want to
maintain the three most recent log files, which cycle
through the names audit.log.1 through
audit.log.3. On Unix, perform
rotation manually like this:
From the command line, rename the current log files:
mv audit.log.2 audit.log.3 mv audit.log.1 audit.log.2 mv audit.log audit.log.1
At this point, the plugin is still writing to the
current log file, which has been renamed to
audit.log.1.
Connect to the server and flush the log file so the
plugin closes it and reopens a new
audit.log file:
SET GLOBAL audit_log_flush = ON;
If
audit_log_rotate_on_size
is greater than 0, setting
audit_log_flush has no
effect. In this case, the audit log plugin closes and
reopens its log file whenever a write to the file causes
its size to exceed the
audit_log_rotate_on_size
value. The plugin renames the original file to have a
timestamp extension. For example,
audit.log might be renamed to
audit.log.13440033615657730. The last
7 digits are a fractional second part. The first 10 digits
are a Unix timestamp value that can be interpreted using
the FROM_UNIXTIME()
function:
mysql> SELECT FROM_UNIXTIME(1344003361);
+---------------------------+
| FROM_UNIXTIME(1344003361) |
+---------------------------+
| 2012-08-03 09:16:01 |
+---------------------------+
The audit_log_policy system
variable controls what kinds of information the plugin writes.
By default, this variable is set to ALL
(write all auditable events), but also permits values of
LOGINS or QUERIES to log
only login or query events, or NONE to
disable logging.
Table 7.8 Audit Log Option/Variable Reference
| Name | Cmd-Line | Option File | System Var | Status Var | Var Scope | Dynamic |
|---|---|---|---|---|---|---|
| audit-log | Yes | Yes | ||||
| audit_log_buffer_size | Yes | Yes | Yes | Global | No | |
| audit_log_file | Yes | Yes | Yes | Global | No | |
| audit_log_flush | Yes | Global | Yes | |||
| audit_log_format | Yes | Yes | Yes | Global | No | |
| audit_log_policy | Yes | Yes | Yes | Global | Yes | |
| audit_log_rotate_on_size | Yes | Yes | Yes | Global | Yes | |
| audit_log_strategy | Yes | Yes | Yes | Global | No |
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:
| Introduced | 5.5.28 | ||
| Command-Line Format | --audit-log[=value] | ||
| Permitted Values | Type | enumeration | |
| Default | ON | ||
| Valid Values | ON | ||
OFF | |||
FORCE | |||
FORCE_PLUS_PERMANENT | |||
This option controls how the server loads the
audit_log plugin at startup. It is
available only if the plugin has been previously registered
with INSTALL PLUGIN or is
loaded with --plugin-load.
See Section 7.2.1, “Installing MySQL Enterprise Audit”.
The option value should be one of those available for
plugin-loading options, as described in
Installing and Uninstalling Plugins. For example,
--audit-log=FORCE_PLUS_PERMANENT
tells the server to load the plugin at startup and prevents
it from being removed while the server is running.
This option was added in MySQL 5.5.28.
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_file | audit.log |
| audit_log_flush | OFF |
| audit_log_policy | ALL |
| audit_log_rotate_on_size | 0 |
| audit_log_strategy | ASYNCHRONOUS |
+--------------------------+--------------+
You can set any of these variables at server startup, and some of them at runtime.
| Introduced | 5.5.28 | ||
| Command-Line Format | --audit_log_buffer_size=value | ||
| System Variable | Name | audit_log_buffer_size | |
| Variable Scope | Global | ||
| Dynamic Variable | No | ||
| Permitted Values (32-bit platforms) | Type | integer | |
| Default | 1048576 | ||
| Min Value | 4096 | ||
| Max Value | 4294967295 | ||
| Permitted Values (64-bit platforms) | Type | integer | |
| Default | 1048576 | ||
| Min Value | 4096 | ||
| Max Value | 18446744073709547520 | ||
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.
This variable was added in MySQL 5.5.28.
| Introduced | 5.5.28 | ||
| Command-Line Format | --audit_log_file=file_name | ||
| System Variable | Name | audit_log_file | |
| Variable Scope | Global | ||
| Dynamic Variable | No | ||
| Permitted Values | Type | file name | |
| Default | audit.log | ||
The name of the file to which the audit log plugin writes
events. The default value is audit.log.
If the file name is a relative path, the server interprets
it relative to the data directory. For security reasons, the
audit log file should be written to a directory accessible
only to the MySQL server and users with a legitimate reason
to view the log.
This variable was added in MySQL 5.5.28.
| Introduced | 5.5.28 | ||
| System Variable | Name | audit_log_flush | |
| Variable Scope | Global | ||
| Dynamic Variable | Yes | ||
| Permitted Values | Type | boolean | |
| Default | OFF | ||
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.
This variable was added in MySQL 5.5.28.
| Introduced | 5.5.34 | ||
| Command-Line Format | --audit_log_format=value | ||
| System Variable | Name | audit_log_format | |
| Variable Scope | Global | ||
| Dynamic Variable | No | ||
| Permitted Values (>= 5.5.34) | Type | enumeration | |
| Default | OLD | ||
| Valid Values | OLD | ||
NEW | |||
The audit log file format. Permitted values are
OLD and NEW (default
OLD). For details about each format, see
Section 7.2.3, “The Audit Log File”.
If you change the value of
audit_log_format, use this
procedure to avoid writing log entries in one format to an
existing log file that contains entries in a different
format:
Stop the server.
Rename the current audit log file manually.
Restart the server with the new value of
audit_log_format. The
audit log plugin will create a new log file, which will
contain log entries in the selected format.
This variable was added in MySQL 5.5.34.
| Introduced | 5.5.28 | ||
| Command-Line Format | --audit_log_policy=value | ||
| System Variable | Name | audit_log_policy | |
| Variable Scope | Global | ||
| Dynamic Variable | Yes | ||
| Permitted Values | Type | enumeration | |
| Default | ALL | ||
| Valid Values | ALL | ||
LOGINS | |||
QUERIES | |||
NONE | |||
The policy controlling the information written by the audit log plugin to its log file. The following table shows the permitted values.
| Value | Description |
|---|---|
ALL | Log all events |
NONE | Log nothing (disable the audit stream) |
LOGINS | Log only login events |
QUERIES | Log only query events |
This variable was added in MySQL 5.5.28.
| Introduced | 5.5.28 | ||
| Command-Line Format | --audit_log_rotate_on_size=N | ||
| System Variable | Name | audit_log_rotate_on_size | |
| Variable Scope | Global | ||
| Dynamic Variable | Yes | ||
| Permitted Values | Type | integer | |
| Default | 0 | ||
If the
audit_log_rotate_on_size
value is greater than 0, the audit log plugin closes and
reopens its log file if a write to the file causes its size
to exceed this value. The original file is renamed to have a
timestamp extension.
If the
audit_log_rotate_on_size
value is 0, the plugin does not close and reopen its log
based on size. Instead, use
audit_log_flush to close
and reopen the log on demand. In this case, rename the file
externally to the server before flushing it.
For more information about audit log file rotation and timestamp interpretation, see Section 7.2.4, “Audit Log Logging Control”.
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.)
This variable was added in MySQL 5.5.28.
| Introduced | 5.5.28 | ||
| Command-Line Format | --audit_log_strategy=value | ||
| System Variable | Name | audit_log_strategy | |
| Variable Scope | Global | ||
| Dynamic Variable | No | ||
| Permitted Values | Type | enumeration | |
| Default | ASYNCHRONOUS | ||
| Valid Values | ASYNCHRONOUS | ||
PERFORMANCE | |||
SEMISYNCHRONOUS | |||
SYNCHRONOUS | |||
The logging method used by the audit log plugin. The following table describes the permitted values.
Table 7.9 Audit Log Strategies
| Value | Meaning |
|---|---|
ASYNCHRONOUS | Log asynchronously, wait for space in output buffer |
PERFORMANCE | Log asynchronously, drop request if insufficient space in output buffer |
SEMISYNCHRONOUS | Log synchronously, permit caching by operating system |
SYNCHRONOUS | Log synchronously, call sync() after each request |
This variable was added in MySQL 5.5.28.
MySQL Enterprise Audit is subject to these general restrictions:
Only SQL statements are logged. Changes made by no-SQL APIs, such as memcached, Node.JS, and the NDB API, are not logged.
Only top-level statements are logged, not statements within stored programs such as triggers or stored procedures.
Contents of files referenced by statements such as
LOAD DATA
INFILE are not logged.
MySQL Cluster. It is possible to use MySQL Enterprise Audit with MySQL Cluster, subject to the following conditions:
All changes to be logged must be done using the SQL interface. Changes using no-SQL interfaces, such as those provided by the NDB API, memcached, or ClusterJ, are not logged.
The plugin must be installed on each MySQL server that is used to execute SQL on the cluster.
Audit plugin data must be aggregated amongst all MySQL servers used with the cluster. This aggregation is the responsibility of the application or user.