Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Explore plugins in MariaDB Server. This section details how to extend database functionality, security, and performance by leveraging various loadable plugins, from authentication to storage engines.
Explore the authentication plugins available in MariaDB, such as ed25519, GSSAPI, and PAM, which provide flexible and secure methods for user verification.
Discover additional plugins that extend MariaDB Server functionality, such as the Disks, Feedback, and Query Response Time plugins, for specialized use cases.
Learn about authentication with Pluggable Authentication Modules (PAM) in MariaDB Server. This section details how to integrate MariaDB with PAM for centralized and flexible user authentication.
The inet4 plugin provides the INET4 data type, allowing for efficient native storage and manipulation of IPv4 addresses as 4-byte binary strings.
This plugin implements the inet4 data type and functions used by this data type, like conversions.
This plugin is built in to MariaDB Server. It cannot be disabled.
inet4 is a data type plugin. It can be used in stored procedures as a variable type and as a data type for table columns.
Password validation plugins, like simple_password_check and cracklib, enforce strong password policies by checking new passwords against defined complexity rules.
This section covers plugins specifically designed for high availability and clustering, including the wsrep_provider plugin used for Galera Cluster integration.
The mhnsw plugin implements the Hierarchical Navigable Small World algorithm, enabling high-performance approximate nearest neighbor search for vector data.
This plugin implements the nhnsw vector index algorithm. It is used to create vector indexes.
See Vector Overview for the functionality, and Vector System Variables for what you can configure.
It is built in the server, and is always enabled.
For plugin version and maturity level, see this page.
The MariaDB Community Audit Plugin (server_audit) records server activity, including connections and queries, to a file or syslog to support auditing and compliance.
MariaDB supports loading plugins at startup or runtime to extend functionality, including storage engines, security features, and logging capabilities, without rebuilding the server.
MariaDB supports the use of plugins, software components that may be added to the core software without having to rebuild the MariaDB server from source code. Plugins can be loaded at startup, or loaded and unloaded while the server is running, without interruption. Plugins are commonly used for adding desired storage engines, additional security requirements, logging special information about the server, or even small enhancements, such as a plugin to get a timestamp as an integer.
There are a number of ways to see which plugins are currently active.
A server almost always has a large number of active plugins, because the server contains a large number of built-in plugins, which are active by default and cannot be uninstalled.
The MariaDB Audit Plugin records server activity, including connections, queries, and table access, to help meet organizational auditing and compliance regulations.
MariaDB and MySQL are used in a broad range of environments, but if you needed to record user access to be in compliance with auditing regulations for your organization, you would previously have had to use other database solutions. To meet this need, though, MariaDB has developed the MariaDB Audit Plugin. Although the MariaDB Audit Plugin has some unique features available only for MariaDB, it can be used also with MySQL.
Basically, the purpose of the MariaDB Audit Plugin is to log the server's activity. For each client session, it records who connected to the server (i.e., user name and host), what queries were executed, and which tables were accessed and server variables that were changed. This information is stored in a rotating log file or it may be sent to the local syslogd.
Review these pages for detailed documentation:
Monitor the performance and status of the Audit Plugin. View variables that track the number of logged events and current settings to ensure the auditing system is functioning correctly.
There are a few status variables related to the , once it has been . These variables can be displayed using the statement like so:
Below is a list of all status variables related to the Audit Plugin. These cannot be set: These are not to be confused with system variables, which can be set. See for a complete list of status variables that can be viewed with the statement. See also the .
The wsrep_provider plugin exposes Galera Cluster provider options as individual system variables, allowing for easier configuration and validation of cluster settings.
This plugin is for . It splits up the wsrep_provider_options setting into individual configuration variables.
Without that plugin, options are grouped together, like this:
With this plugin loaded, you can configure individual variables, like this:
This makes managing provider options easier, and helps avoid the problem of wsrep_provider_options exceeding the maximum length of 2048 characters for an individual variable.
The MYSQL_JSON plugin provides a JSON data type alias for compatibility, ensuring that tables created with the MySQL JSON type can be read by MariaDB.
The JSON type in MySQL stores the JSON object in its own native form, while, in MariaDB, the is a . Opening a table with a JSON type created in MySQL results in an error:
The mysql_json plugin is used to make it easier to upgrade to MariaDB.
Activating MariaDB Audit Log by Jaykishan Mutkawoa, May 30, 2016
Installing MariaDB Audit Plugin on Amazon RDS Amazon RDS supports using the MariaDB Audit Plugin on MySQL and MariaDB database instances.
MySQL Auditing with MariaDB Auditing Plugin by Peter Zaitsev, February 15, 2016
The online_alter_log plugin provides logging capabilities for online ALTER TABLE operations, helping administrators monitor and debug schema changes.
This plugin represents the online alter log in a transaction. It is used to commit transactions for tables while an online ALTER TABLE query is running.
It is built in the server, and is always enabled.
See the Online Schema Change page for functionality details.
For plugin version and maturity level, see this page.
SHOW PLUGINSThe SHOW PLUGINS statement can be used to query information about all active plugins.
For example:
If a plugin's Library column has a NULL value, then the plugin is built-in, and it cannot be uninstalled.
The information_schema.PLUGINS table can be queried to get more detailed information about plugins.
For example:
If a plugin's PLUGIN_LIBRARY column has the NULL value, the plugin is built-in and cannot be uninstalled.
The mysql.plugin table can be queried to get information about installed plugins.
This table only contains information about plugins that have been installed via the following methods:
The INSTALL SONAME statement.
The INSTALL PLUGIN statement.
The mariadb-plugin utility.
This table does not contain information about:
Built-in plugins.
Plugins loaded with the --plugin-load-add option.
Plugins loaded with the --plugin-load option.
This table only contains enough information to reload the plugin when the server is restarted, which means it only contains the plugin name and the plugin library.
For example:
There are three primary ways to install a plugin:
A plugin can be installed dynamically with an SQL statement.
A plugin can be installed with a mariadbd option, but it requires a server restart.
A plugin can be installed with the mariadb-plugin utility, while the server is completely offline.
When you are installing a plugin, you also have to ensure that:
The server's plugin directory is properly configured, and the plugin's library is in the plugin directory.
The server's minimum plugin maturity is properly configured, and the plugin is mature enough to be installed.
A plugin can be installed dynamically by executing either the INSTALL SONAME or the INSTALL PLUGIN statement.
If a plugin is installed with one of these statements, a record will be added to the mysql.plugins table for the plugin. This means that the plugin will automatically be loaded every time the server restarts, unless specifically uninstalled or deactivated.
You can install a plugin dynamically by executing the INSTALL SONAME statement. INSTALL SONAME installs all plugins from the given plugin library. This could be required for some plugin libraries.
For example, to install all plugins in the server_audit plugin library (which is currently only the server_audit audit plugin), you could execute the following:
You can install a plugin dynamically by executing the INSTALL PLUGIN statement. INSTALL PLUGIN installs a single plugin from the given plugin library.
For example, to install the server_audit audit plugin from the server_audit plugin library, you could execute the following:
A plugin can be installed with a mariadbd option by providing either the --plugin-load-add or the --plugin-load option.
If a plugin is installed with one of these options, then a record will not be added to the mysql.plugins table for the plugin. This means that if the server is restarted without the same option set, then the plugin will not automatically be loaded.
You can install a plugin with the --plugin-load-add option by specifying the option as a command-line argument to mariadbd or by specifying the option in a relevant server option group in an option file.
The --plugin-load-add option uses the following format:
Plugins can be specified in the format name=library, where name is the plugin name and library is the plugin library. This format installs a single plugin from the given plugin library.
Plugins can also be specified in the format library, where library is the plugin library. This format installs all plugins from the given plugin library.
Multiple plugins can be specified by separating them with semicolons.
For example, to install all plugins in the server_audit plugin library (which is currently only the server_audit audit plugin) and also the ed25519 authentication plugin from the auth_ed25519 plugin library, you could set the option to the following values on the command-line:
You could also set the option to the same values in an option file:
Special care must be taken when specifying both the --plugin-load option and the --plugin-load-add option together. The --plugin-load option resets the plugin load list, and this can cause unexpected problems if you are not aware. The --plugin-load-add option does not reset the plugin load list, so it is much safer to use. See Specifying Multiple Plugin Load Options for more information.
You can install a plugin with the --plugin-load option by specifying the option as a command-line argument to mariadbd or by specifying the option in a relevant server option group in an option file.
The --plugin-load option uses the following format:
Plugins can be specified in the format name=library, where name is the plugin name and library is the plugin library. This format installs a single plugin from the given plugin library.
Plugins can also be specified in the format library, where library is the plugin library. This format installs all plugins from the given plugin library.
Multiple plugins can be specified by separating them with semicolons.
For example, to install all plugins in the server_audit plugin library (which is currently only the server_audit audit plugin) and also the ed25519 authentication plugin from the auth_ed25519 plugin library, you could set the option to the following values on the command-line:
You could also set the option to the same values in an option file:
Special care must be taken when specifying the --plugin-load option multiple times, or when specifying both the --plugin-load option and the --plugin-load-add option together. The --plugin-load option resets the plugin load list, and this can cause unexpected problems if you are not aware. The --plugin-load-add option does not reset the plugin load list, so it is much safer to use. See Specifying Multiple Plugin Load Options for more information.
Special care must be taken when specifying the --plugin-load option multiple times, or when specifying both the --plugin-load option and the --plugin-load-add option. The --plugin-load option resets the plugin load list, and this can cause unexpected problems if you are not aware. The --plugin-load-add option does not reset the plugin load list, so it is much safer to use.
This can have the following consequences:
If the --plugin-load option is specified multiple times, then only the last instance will have any effect. For example, in the following case, the first instance of the option is reset:
If the --plugin-load option is specified after the --plugin-load-add option, then it will also reset the changes made by that option. For example, in the following case, the --plugin-load-add option does not do anything, because the subsequent --plugin-load option resets the plugin load list:
In contrast, if the --plugin-load option is specified before the --plugin-load-add option, then it will work fine, because the --plugin-load-add option does not reset the plugin load list. For example, in the following case, both plugins are properly loaded:
A plugin can be installed with the mariadb-plugin utility if the server is completely offline.
The syntax is:
For example, to install the server_audit audit plugin, you could execute the following:
If a plugin is installed with this utility, a record will be added to the mysql.plugins table for the plugin. This means that the plugin will automatically be loaded every time the server restarts, unless specifically uninstalled or deactivated.
When a plugin is being installed, the server looks for the plugin's library in the server's plugin directory. This directory is configured by the plugin_dir system variable. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:
When a plugin is being installed, the server compares the plugin's maturity level against the server's minimum allowed plugin maturity. This can help prevent users from using unstable plugins on production servers. This minimum plugin maturity is configured by the plugin_maturity system variable. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:
A plugin will be loaded by default when the server starts if:
The plugin was installed with the INSTALL SONAME statement.
The plugin was installed with the INSTALL PLUGIN statement.
The plugin was installed with the mariadb-plugin utility.
The server is configured to load the plugin with the --plugin-load-add option.
The server is configured to load the plugin with the option.
This behavior can be changed with special options that take the form --plugin-name. For example, for the server_audit audit plugin, the special option is called --server-audit.
The possible values for these special options are:
OFF
Disables the plugin without removing it from the table.
ON
Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE
Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT
Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
A plugin's status can be found by looking at the PLUGIN_STATUS column of the information_schema.PLUGINS table.
Plugins that are found in the mysql.plugin table, that is those that were installed with INSTALL SONAME, INSTALL PLUGIN or mariadb-plugin can be uninstalled in one of two ways:
The UNINSTALL SONAME or the UNINSTALL PLUGIN statement while the server is running
With mariadb-plugin while the server is offline.
Plugins that were enabled as a --plugin-load option do not need to be uninstalled. If --plugin-load is omitted the next time the server starts, or the plugin is not listed as one of the --plugin-load entries, the plugin will not be loaded.
UNINSTALL PLUGIN uninstalls a single installed plugin, while UNINSTALL SONAME uninstalls all plugins belonging to a given library.
This page is licensed: CC BY-SA / Gnu FDL
Server_audit_activeDescription: If the auditing is actually working. It gets the ON value when the logging is successfully started. Then it can get the OFF value if the logging was stopped or log records can't be properly stored due to file or syslog errors.
Data Type: boolean
Description: The name of the logfile or the SYSLOG parameters that are in current use.
Data Type: string
Description: If something went wrong with the logging here you can see the message.
Data Type: string
Description: The number of log records since last logging-start that weren't properly stored because of errors of any kind. The global value can be flushed by FLUSH STATUS.
Data Type: numeric
Default Value: 0
This page is licensed: CC BY-SA / Gnu FDL
[mariadbd], [server], or [galera] sections of your server option file:Alternatively, start the server with the --plugin-wsrep-provider option.
See the page for what you can configure for Galera Cluster.
For plugin version and maturity level, see this page.
wsrep_provider_options="base_dir = /var/lib/mysql/; base_host = node-1;..."wsrep_provider_base_dir = /var/lib/mysql/
wsrep_provider_base_host = node-1
...plugin-wsrep-provider=ONInstalling can be done in a number of ways, for example:
See Making MariaDB understand MySQL JSON for a full description.
This page is licensed: CC BY-SA / Gnu FDL
SELECT * FROM mysql_json_table;
ERROR 4161 (HY000): Unknown data type: 'MYSQL_JSON'INSTALL SONAME 'type_mysql_json';This system variable defines the retention period in days for the password history used by the Password Reuse Check Plugin to prevent reuse.
The password_reuse_check_interval system variable is available when the password_reuse_check plugin is installed. It determines the retention period for the password history in days. Zero, the default, means that passwords are never discarded.
Command line: --password_reuse_check_interval=#
Scope: Global
Read-only: No
Data Type: numeric
Default Value: 0
Range: 0 to 36500
This page is licensed: CC BY-SA / Gnu FDL
SHOW PLUGINS\G;
********************** 1. row **********************
Name: binlog
Status: ACTIVE
Type: STORAGE ENGINE
Library: NULL
License: GPL
********************** 2. row **********************
Name: mysql_native_password
Status: ACTIVE
Type: AUTHENTICATION
Library: NULL
License: GPL
********************** 3. row **********************
Name: mysql_old_password
Status: ACTIVE
Type: AUTHENTICATION
Library: NULL
License: GPL
...SELECT * FROM information_schema.PLUGINS\G
...
*************************** 65. row ***************************
PLUGIN_NAME: user_variables
PLUGIN_VERSION: 1.0
PLUGIN_STATUS: ACTIVE
PLUGIN_TYPE: INFORMATION SCHEMA
PLUGIN_TYPE_VERSION: 110600.0
PLUGIN_LIBRARY: NULL
PLUGIN_LIBRARY_VERSION: NULL
PLUGIN_AUTHOR: Sergey Vojtovich
PLUGIN_DESCRIPTION: User-defined variables
PLUGIN_LICENSE: GPL
LOAD_OPTION: ON
PLUGIN_MATURITY: Stable
PLUGIN_AUTH_VERSION: 1.0
*************************** 66. row ***************************
PLUGIN_NAME: wsrep_provider
PLUGIN_VERSION: 1.0
PLUGIN_STATUS: ACTIVE
PLUGIN_TYPE: REPLICATION
PLUGIN_TYPE_VERSION: 2.0
PLUGIN_LIBRARY: NULL
PLUGIN_LIBRARY_VERSION: NULL
PLUGIN_AUTHOR: Codership Oy
PLUGIN_DESCRIPTION: Wsrep provider plugin
PLUGIN_LICENSE: GPL
LOAD_OPTION: ON
PLUGIN_MATURITY: Alpha
PLUGIN_AUTH_VERSION: 1.0
*************************** 67. row ***************************
PLUGIN_NAME: THREAD_POOL_GROUPS
PLUGIN_VERSION: 1.0
PLUGIN_STATUS: ACTIVE
PLUGIN_TYPE: INFORMATION SCHEMA
PLUGIN_TYPE_VERSION: 110600.0
PLUGIN_LIBRARY: NULL
PLUGIN_LIBRARY_VERSION: NULL
PLUGIN_AUTHOR: Vladislav Vaintroub
PLUGIN_DESCRIPTION: Provides information about threadpool groups.
PLUGIN_LICENSE: GPL
LOAD_OPTION: ON
PLUGIN_MATURITY: Stable
PLUGIN_AUTH_VERSION: 1.0
...SELECT * FROM mysql.plugin;
+------+------------+
| name | dl |
+------+------------+
| PBXT | libpbxt.so |
+------+------------+INSTALL SONAME 'server_audit';INSTALL PLUGIN server_audit SONAME 'server_audit';$ mariadbd --user=mysql --plugin-load-add='server_audit' --plugin-load-add='ed25519=auth_ed25519'[mariadb]
...
plugin_load_add = server_audit
plugin_load_add = ed25519=auth_ed25519$ mariadbd --user=mysql --plugin-load='server_audit;ed25519=auth_ed25519'[mariadb]
...
plugin_load = server_audit;ed25519=auth_ed25519[mariadb]
...
plugin_load = server_audit
plugin_load = ed25519=auth_ed25519[mariadb]
...
plugin_load_add = server_audit
plugin_load = ed25519=auth_ed25519[mariadb]
...
plugin_load = server_audit
plugin_load_add = ed25519=auth_ed25519mariadb-plugin [options] <plugin> ENABLE|DISABLEmariadb-plugin server_audit ENABLE[mariadb]
...
plugin_dir = /usr/lib64/mysql/plugin[mariadb]
...
plugin_maturity = stableSHOW STATUS LIKE 'server_audit%';
+----------------------------+------------------+
| Variable_name | Value |
+----------------------------+------------------+
| Server_audit_active | ON |
| Server_audit_current_log | server_audit.log |
| Server_audit_last_error | |
| Server_audit_writes_failed | 0 |
+----------------------------+------------------+This page lists the maturity level (Alpha, Beta, Gamma, Stable) of various MariaDB plugins, helping users determine which are suitable for production environments.
The following table lists the various plugins included in MariaDB ordered by their maturity. Note that maturity will differ across MariaDB versions - see below for an easy way to get a complete list of plugins and their maturity in your version of MariaDB:
3.0
Stable
1.6
Stable
This query shows a complete list of plugins and their maturity level:
This page is licensed: CC BY-SA / Gnu FDL
This plugin provides backward compatibility for pre-4.1 clients using an older, insecure password hashing algorithm and should not be used for new installations.
The mysql_old_password authentication plugin is the default authentication plugin that is used for an account created when no authentication plugin is explicitly mentioned and old_passwords=1 is set. It uses the pre-MySQL 4.1 password hashing algorithm, which is also used by the OLD_PASSWORD() function and by the PASSWORD() function when old_passwords=1 is set.
It is not recommended to use the mysql_old_password authentication plugin for new installations. The password hashing algorithm is no longer secure, and the plugin is primarily provided for backward compatibility. The ed25519 authentication plugin is a more modern authentication plugin that provides simple password authentication.
The mysql_old_password authentication plugin is statically linked into the server, so no installation is necessary.
The easiest way to create a user account with the mysql_old_password authentication plugin is to make sure that is set, and create a user account via that does not specify an authentication plugin, but instead specifies a password via the clause:
If does not have NO_AUTO_CREATE_USER set, then you can also create the user via :
You can also create the user account by providing a password hash via the clause, and MariaDB validates whether the password hash is one that is compatible with mysql_old_password:
Similar to all other , you could also specify the name of the plugin in the IDENTIFIED VIA clause, while providing the password hash as the USING clause:
You can change a user account's password with the statement, while providing the plain-text password as an argument to the function:
You can also change the user account's password with the statement. You have to make sure that is set, and you have to specify a password via the clause:
For clients that use the libmysqlclient or libraries, MariaDB provides one client authentication plugin that is compatible with the mysql_old_password authentication plugin:
mysql_old_password
When connecting with a to a server as a user account that authenticates with the mysql_old_password authentication plugin. You may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:
However, the mysql_old_password client authentication plugin is generally statically linked into client libraries like libmysqlclient or , so this is not usually necessary.
mysql_old_passwordThe mysql_old_password client authentication plugin hashes the password before sending it to the server.
The mysql_old_password authentication plugin is one of the conventional authentication plugins, so all client libraries should support it.
This page is licensed: CC BY-SA / Gnu FDL
Understand the structure of audit log entries. This guide breaks down the fields in the log records, including timestamps, server IDs, user details, and the specific operations performed.
The audit plugin logs user access to MariaDB and its objects. The audit trail (that is, the audit log) is a set of records, written as a list of fields to a file in a plain‐text format. The fields in the log are separated by commas. The format used for the plugin's own log file is slightly different from the format used if it logs to the system log because it has its own standard format. The general format for the logging to the plugin's own file is defined like the following:
If the server_audit_output_type variable is set to syslog instead of the default, file, the audit log file format is as follows:
timestamp
Various events result in different audit records. Some events do not return a value for some fields (for instance, when the active database is not set when connecting to the server).
Below is a generic example of the output for connect events, with placeholders representing data. These are events in which a user connected, disconnected, or tried unsuccessfully to connect to the server.
Here is the one audit record generated for each query event:
Below are generic examples of records that are entered in the audit log for each type of table event:
Passwords are hidden in the log for certain types of queries. They are replaced with asterisks for GRANT, CREATE USER, CREATE MASTER, CREATE SERVER, and ALTER SERVER statements. Passwords, however, are not replaced for the PASSWORD() and OLD_PASSWORD() functions when they are used inside other SQL statements (i.e., SET PASSWORD).
For applier operations, audit log plugin logs events with a generic name of <wsrep_applier> .
This addresses an issue where the user was logged on the primary node, but stripped from other cluster nodes. See for details.
For Galera Cluster replication applier operations, audit log plugin logs events without indicating what user initiates them.
This page is licensed: CC BY-SA / Gnu FDL
Review the version history of the MariaDB Audit Plugin. Check compatibility with different MariaDB Server releases and identify which features or bug fixes are included in each version.
Below is a list of the releases of the MariaDB Audit Plugin, the most recent version first, and in which versions of MariaDB each plugin version was included.
1.5.0
1.4.14
, , , ,
1.4.13
, , ,
This page is licensed: CC BY-SA / Gnu FDL
Follow this guide to install the Audit Plugin on your MariaDB server. Learn how to verify the plugin file's location, load it dynamically, or configure it to load automatically at startup.
The server_audit plugin logs the server's activity. For each client session, it records who connected to the server (i.e., user name and host), what queries were executed, and which tables were accessed and server variables that were changed. This information is stored in a rotating log file or it may be sent to the local syslogd.
The server_audit plugin's shared library is included in MariaDB packages as the server_audit.so or server_audit.dll shared library on systems where it can be built.
The plugin must be located in the plugin directory, the directory containing all plugin libraries for MariaDB. The path to this directory is configured by the system variable. To see the value of this variable and thereby determine the file path of the plugin library, execute the following SQL statement:
Check the directory returned at the filesystem level to make sure that you have a copy of the plugin library, server_audit.so or server_audit.dll, depending on your system. It's included in recent installations of MariaDB. If you do not have it, you should upgrade MariaDB.
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to mariadbd , or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
The or statements may be used to uninstall plugins. For the server_audit plugin, you might want to disable this capability. To prevent the plugin from being uninstalled, you could set the option to FORCE_PLUS_PERMANENT in a relevant server in an after the plugin is loaded once:
Once you've added the option to the server's option file and restarted the server, the plugin can't be uninstalled. If someone tries to uninstall the audit plugin, then an error message will be returned. Below is an example of the error message:
For more information on FORCE_PLUS_PERMANENT and other option values for the option, see for more information.
This page is licensed: CC BY-SA / Gnu FDL
The User Variables plugin adds the USER_VARIABLES table to the Information Schema, allowing users to inspect defined user variables and their values.
The user_variables plugin creates the USER_VARIABLES table in the INFORMATION_SCHEMA database. This table contains information about user-defined variables.
User-defined variables can be viewed by either querying the USER_VARIABLES, or by running SHOW USER_VARIABLES.
User-defined variables are reset and the Information Schema table emptied with the statement.
If it is not installed, however, here are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
user_variablesDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
This plugin exposes the contents of the query cache via the QUERY_CACHE_INFO table in the Information Schema, aiding in performance analysis.
The QUERY_CACHE_INFO plugin creates the QUERY_CACHE_INFO table in the INFORMATION_SCHEMA database. This table shows all queries in the query cache. Querying this table acquires the query cache lock and will result in lock waits for queries that are using or expiring from the query cache. You must have the PROCESS privilege to query this table.
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
query_cache_infoDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
The mysql_native_password plugin is the default legacy authentication method, using SHA-1 hashing to verify passwords stored in the internal mysql.user table.
The mysql_native_password authentication plugin is the default authentication plugin that will be used for an account created when no authentication plugin is explicitly mentioned and is set. It uses the password hashing algorithm introduced in MySQL 4.1, which is also used by the function when is set. This hashing algorithm is based on .
It is not recommended to use the mysql_native_password authentication plugin for new installations that require high password security. If someone is able to both listen to the connection protocol and get a copy of the mysql.user table, then the person would be able to use this information to connect to the MariaDB server. The authentication plugin is a more modern authentication plugin that provides simple password authentication using a more secure algorithm.
Configure the Audit Plugin to suit your monitoring requirements. Learn how to enable logging, select specific event types to record, and exclude specific users from the audit trail.
After the audit plugin has been installed and loaded, there will be some new global variables within MariaDB. These can be used to configure many components, limits, and methods related to auditing the server. You may set these variables related to the logs, such as their location, size limits, rotation parameters, and method of logging information. You may also set what information is logged, such connects, disconnects, and failed attempts to connect. You can also have the audit plugin log queries, read and write access to tables. So as not to overload your logs, the audit plugin can be configured based on lists of users. You can include or exclude the activities of specific users in the logs.
To see a list of on the server and their values, execute the follow while connected to the server:
The values of these variables can be changed by an administrator with the SUPER privilege, using the statement. Below is an example of how to disable audit logging:
Although it is possible to change all of the variables shown above, some of them may be reset when the server restarts. Therefore, you may want set them in the configuration file (e.g.,
The Simple Password Check Plugin enforces basic password complexity rules, such as minimum length and required numbers of digits, letters, and special characters.
simple_password_check is a plugin. It can check whether a password contains at least a certain number of characters of a specific type. When first installed, a password is required to be at least eight characters, and requires at least one digit, one uppercase character, one lowercase character, and one character that is neither a digit nor a letter.
Note that passwords can be directly set as a hash, bypassing the password validation, if the variable is OFF (it is ON by default).
The SHA-256 authentication plugin uses the SHA-256 hashing algorithm for password storage, offering stronger security than the default SHA-1 method.
PARSEC is a modern, secure authentication plugin that uses salted passwords and elliptic curve cryptography to prevent replay attacks and secure user credentials.
The PARSEC Authentication Plugin is intended to be the default in a future release.
The PARSEC (Password Authentication using Response Signed with Elliptic Curve) authentication plugin uses salted passwords, key derivation, extensible password storage format, and both server- and client-side scrambles.
It signs the response with ed25519, but it uses stock unmodified ed25519
[timestamp],[serverhost],[username],[host],[connectionid],
[queryid],[operation],[database],[object],[retcode][timestamp][syslog_host][syslog_ident]:[syslog_info][serverhost],[username],[host],
[connectionid],[queryid],[operation],[database],[object],[retcode]ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --user-variables=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --query-cache-info=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
/etc/my.cnf.d/server.cnfFor the reason given in the paragraph above, you would not generally set variables related to the auditing plugin using the SET statement. However, you might do so to test settings before making them more permanent. Since one cannot always restart the server, you would use the SET statement to change immediately the variables and then include the same settings in the configuration file so that the variables are set again as you prefer when the server is restarted.
Of all of the server variables you can set, you may want to set initially the server_audit_events variable to tell the Audit Plugin which events to log. The Log Settings documentation page describes in detail the choices you have and provides examples of log entries related to them.
You can see a detailed list of system variables related to the MariaDB Audit Plugin on the System Variables documentation page. Status variables related to the Audit Plugin are listed and explained on the Status Variables documentation page.
This page is licensed: CC BY-SA / Gnu FDL
SHOW GLOBAL VARIABLES LIKE 'server_audit%';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| server_audit_events | |
| server_audit_excl_users | |
| server_audit_file_buffer_size | 0 |
| server_audit_file_path | server_audit.log |
| server_audit_file_rotate_now | OFF |
| server_audit_file_rotate_size | 1000000 |
| server_audit_file_rotations | 9 |
| server_audit_incl_users | |
| server_audit_logging | OFF |
| server_audit_mode | 0 |
| server_audit_output_type | file |
| server_audit_query_log_limit | 1024 |
| server_audit_sync_log_file | OFF |
| server_audit_syslog_facility | LOG_USER |
| server_audit_syslog_ident | mysql-server_auditing |
| server_audit_syslog_info | |
| server_audit_syslog_priority | LOG_INFO |
+-------------------------------+-----------------------+
17 rows in set (0.003 sec)SHOW GLOBAL VARIABLES LIKE 'plugin_dir';
+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| plugin_dir | /usr/lib64/mysql/plugin/ |
+---------------+--------------------------+INSTALL SONAME 'server_audit';[mariadb]
...
plugin_load_add = server_auditUNINSTALL SONAME 'server_audit';[mariadb]
...
plugin_load_add = server_audit
server_audit=FORCE_PLUS_PERMANENTUNINSTALL PLUGIN server_audit;
ERROR 1702 (HY000):
Plugin 'server_audit' is force_plus_permanent and can not be unloadedSET @v1 = 0;
SET @v2 = 'abc';
SET @v3 = CAST(123 AS CHAR(5));
SHOW USER_VARIABLES;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| v3 | 123 |
| v2 | abc |
| v1 | 0 |
+---------------+-------+
SELECT * FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;
+---------------+----------------+---------------+--------------------+
| VARIABLE_NAME | VARIABLE_VALUE | VARIABLE_TYPE | CHARACTER_SET_NAME |
+---------------+----------------+---------------+--------------------+
| v1 | 0 | INT | latin1 |
| v2 | abc | VARCHAR | utf8 |
| v3 | 123 | VARCHAR | utf8 |
+---------------+----------------+---------------+--------------------+
FLUSH USER_VARIABLES;
SELECT * FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;
Empty set (0.000 sec)INSTALL SONAME 'user_variables';[mariadb]
...
plugin_load_add = user_variablesUNINSTALL SONAME 'user_variables';INSTALL SONAME 'query_cache_info';[mariadb]
...
plugin_load_add = query_cache_infoUNINSTALL SONAME 'query_cache_info';SELECT statement_schema, statement_text, result_blocks_count,
result_blocks_size FROM information_schema.query_cache_info;
+------------------+------------------+---------------------+--------------------+
| statement_schema | statement_text | result_blocks_count | result_blocks_size |
+------------------+------------------+---------------------+--------------------+
| test | SELECT * FROM t1 | 1 | 512 |
+------------------+------------------+---------------------+--------------------+SHOW GLOBAL VARIABLES LIKE 'server_audit%';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| server_audit_events | CONNECT,QUERY,TABLE |
| server_audit_excl_users | |
| server_audit_file_path | server_audit.log |
| server_audit_file_rotate_now | OFF |
| server_audit_file_rotate_size | 1000000 |
| server_audit_file_rotations | 9 |
| server_audit_incl_users | |
| server_audit_logging | ON |
| server_audit_mode | 0 |
| server_audit_output_type | file |
| server_audit_query_log_limit | 1024 |
| server_audit_syslog_facility | LOG_USER |
| server_audit_syslog_ident | mysql-server_auditing |
| server_audit_syslog_info | |
| server_audit_syslog_priority | LOG_INFO |
+-------------------------------+-----------------------+SET GLOBAL server_audit_logging=OFF;[server]
...
server_audit_logging=OFF
…1.4
Stable
1.0
Stable
2.0
Stable
1.0
Stable
1.7
Stable
2.0
Stable
1.0
Stable
1.0
Stable
1.0
Gamma
1.1
Stable
1.1
Stable
2.1
Stable
1.1
Stable
2.0
Gamma
1.0
Stable
2.0
Stable
1.0
Gamma
1.0
Stable
10.*
Stable
1.0
Stable
1.0
Stable
0.1
Stable
1.0
Stable
1.0
Stable
7.7
Stable
1.0
Stable
1.0
Stable
0.1
Stable
1.0
Stable
1.0
Stable
1.0
Stable
2.0
Stable
1.0
Stable
2.0
Stable (introduced in 10.10.2, 10.9.5, and 10.8.7)
partition
1.0
Stable
0.1
Stable
1.1
Stable
1.0
Stable
1.0
Stable
1.0
Stable
1.0
Stable
2.6
Stable
1.0
Stable
3.3
Stable
1.0
Stable
1.0
Gamma
2.0
Stable
2.0
Stable
1.0
Stable
4.0
Stable (removed in 10.6)
1.1
Stable
1.0
Stable (introduced in 10.9.1)
1.0
Stable
1.0
Stable
1.0
Stable
1.0
Stable
1.0
Stable
1.0
Stable
1.0
Stable
3.0
Gamma
2.0
Gamma
1.0
Beta
1.0
Beta
0.1
Experimental (removed in 10.6)
1.0
Experimental
1.0
Experimental
The mysql_native_password authentication plugin is statically linked into the server, so no installation is necessary.
The easiest way to create a user account with the mysql_native_password authentication plugin is to make sure that old_passwords=0 is set, and then create a user account via CREATE USER that does not specify an authentication plugin, but does specify a password via the IDENTIFIED BY clause:
If SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:
You can also create the user account by providing a password hash via the IDENTIFIED BY PASSWORD clause, and MariaDB will validate whether the password hash is one that is compatible with mysql_native_password:
Similar to all other authentication plugins, you could also specify the name of the plugin in the IDENTIFIED VIA clause while providing the password hash as the USING clause:
You can change a user account's password with the SET PASSWORD statement while providing the plain-text password as an argument to the PASSWORD() function:
You can also change the user account's password with the ALTER USER statement. You would have to make sure that old_passwords=0 is set, and then you would have to specify a password via the IDENTIFIED BY clause:
For clients that use the libmysqlclient or libraries, MariaDB provides one client authentication plugin that is compatible with the mysql_native_password authentication plugin:
mysql_native_password
When connecting with a client or utility to a server as a user account that authenticates with the mysql_native_password authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:
However, the mysql_native_password client authentication plugin is generally statically linked into client libraries like libmysqlclient or , so this is not usually necessary.
The mysql_native_password client authentication plugin hashes the password before sending it to the server.
The mysql_native_password authentication plugin is one of the conventional authentication plugins, so all client libraries should support it.
For compatibility reasons, the mysql_native_password authentication plugin tries to read the password hash from both the Password and authentication_string columns in the mysql.user table. This has caused issues in the past if one of the columns had a different value than the other.
CREATE USER, ALTER USER, GRANT, and SET PASSWORD set the Password and authentication_string columns in the mysql.user table whenever an account's password is changed.
CREATE USER, ALTER USER, GRANT, and SET PASSWORD do not set the Password and authentication_string columns in the mysql.user table whenever an account's password is changed.
ed25519 secure connection plugin
This page is licensed: CC BY-SA / Gnu FDL
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
When creating a new password, if the criteria are not met, the following error is returned:
Description: A password must contain at least this many digits.
Command line: --simple-password-check-digits=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 1
Range: 0 to 1000
Description: A password must contain at least this many upper-case and this many lower-case letters.
Command line: --simple-password-check-letters-same-case=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 1
Range: 0 to 1000
Description: A password must contain at least this many characters.
Command line: --simple-password-check-minimal-length=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 8
Range: 0 to 1000
Description: A password must contain at least this many characters that are neither digits nor letters.
Command line: --simple-password-check-other-characters=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 1
Range: 0 to 1000
Description: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --simple-password-check=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
cracklib_password_check plugin - use the Cracklib password-strength checking library
This page is licensed: CC BY-SA / Gnu FDL
MariaDB Server does not support the sha256_password plugin. A caching_sha2_password authentication plugin was added in MariaDB Community Server 12.1 and . See MDEV-9804 for more information.
Reasons for not supporting the SHA-256 plugin:
To use the protocol, you have to distribute the server's public key to all MariaDB users, which can be cumbersome and impractical.
The server receives the password in clear text, which can cause problems if the user connects to a malicious server.
If you are migrating from a MySQL instance that is using SHA-256 authentication, you have to change the SHA-256 authentication to mysql_native_authentication :
For clients that use the library, MariaDB provides client authentication plugins that are compatible with MySQL's SHA-256 authentication plugins:
sha256_password
caching_sha256_password
When connecting with a client or utility to a server, using a user account that authenticates with the sha256_password or caching_sha256_password authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:
For clients that use MariaDB's libmysqlclient library instead of , those authentication plugins are not supported.
The sha256_password client authentication plugin is compatible with MySQL's sha256_password authentication plugin, which was added in MySQL 5.6.
The caching_sha256_password client authentication plugin is compatible with MySQL's caching_sha2_password authentication plugin, which was added in MySQL 8.0.
The caching_sha2_password plugin is now the default authentication plugin in MySQL 8.0.4 and above, based on the value of the default_authentication_plugin system variable.
supports sha256_password and caching_sha2_password authentication using the client authentication plugins mentioned in the previous section.
It has supported the sha256_password client authentication plugin since MariaDB Connector/C 3.0.2. See CONC-229 for more information.
It has supported the caching_sha256_password client authentication plugin since MariaDB Connector/C 3.0.8 and MariaDB Connector/C 3.1.0. See CONC-312 for more information.
supports sha256_password and caching_sha2_password authentication using the client authentication plugins mentioned in the previous section.
It has supported sha256_password and caching_sha2_password authentication since MariaDB Connector/ODBC 3.1.4. See ODBC-241 for more information.
supports sha256_password and caching_sha2_password authentication since MariaDB Connector/J 2.5.0. See CONJ-327 and CONJ-663 for more information.
note: The version 3.x being a rewrite of the connector, only caching_sha2_password is implemented, since sha256_password is only implemented on EOL version.
supports sha256_password and caching_sha2_password authentication since MariaDB Connector/Node.js 2.5.0. See CONJS-76 and CONJS-77 for more information.
MDEV-9804 contains the plans to use if we ever decide to support these protocols.
This page is licensed: CC BY-SA / Gnu FDL
The KDF function is pbkdf2 (supported by everything, including windows native, Java, javascript, PHP, .NET.
Parameters to the pbkdf2 are stored in with authentication plugin data : hash function (SHA512,SHA256), iteration count, salt, key_length, together with derived key = PBKDF2(func, password, salt, iteration_count, key_length).
The number of iterations is a power of 2, greater than 9.
The algorithm is ed25519, "hash" is the public key generated using ed25519 from the PBKDF2(password).
The authentication string, stored by the server, is this:
For example, it looks like this: P0:WW9sXaaL/o:vubFBzIrapbfHct1/J72dnUryz5VS7lA6XHH8sIx4TI
It consists of colon-separated fields.
The first field is 'P' (denotes KDF algorithm = PBKDF2) and the number of iterations, '0' means 1024, '1' means 2048, etc.
This is followed by the salt.
This is followed by the password hash.
The first two fields together are called ext-salt, extended salt.
The server sends an Authentication Switch Request with a 32-byte random scramble.
The client sends an empty packet to the server to request the ext-salt.
The server sends the ext-salt to the client.
The client sends the random 32-byte scramble, and the concat(server scramble, client scramble) ed25519-signed by a secret key generated from the function PBKDF2(password, ext-salt).
The server replies with or .
If you run into the error ERROR 1524 (HY000): Plugin 'parsec' is not loaded it means you need to install the authentication plugin first. You can do it on a running server with:
There is no need to pass additional command-line options or have config files to keep the PARSEC authentication method available. Running the INSTALL SONAME once is enough and the MariaDB Server will remember it even if server is restarted or upgraded.
PARSEC is currently available in latest MariaDB versions, but not installed or used by default yet. Once MDEV-12320 is implemented, MariaDB plans to start using PARSEC as the default password authentication method.
This page is licensed: CC BY-SA / Gnu FDL
Time at which the event occurred. If syslog is used, the format is defined by syslogd.
syslog_host
Host from which the syslog entry was received.
syslog_ident
For identifying a system log entry, including the MariaDB server.
syslog_info
For providing information for identifying a system log entry.
serverhost
The MariaDB server host name.
username
Connected user.
host
Host from which the user connected.
connectionid
Connection ID number for the related operation.
queryid
Query ID number, which can be used for finding the relational table events and related queries. For TABLE events, multiple lines will be added.
operation
Recorded action type: CONNECT, QUERY, READ, WRITE, CREATE, ALTER, RENAME, DROP.
database
Active database (as set by USE).
object
Executed query for QUERY events, or the table name in the case of TABLE events. From MariaDB 12.0, CONNECTION events also contain the tls version used, for example TLSv1.3.
retcode
Return code of the logged operation.
1.4.10
, ,
1.4.7
, , ,
1.4.5
, ,
1.4.4
, , , , ,
1.4.0
, ,
1.3.0
, ,
1.2.0
, ,
, ,
,
,
The Disks plugin adds the DISKS table to the Information Schema, providing metadata about the system's disk storage and usage.
The DISKS plugin creates the DISKS table in the INFORMATION_SCHEMA database. This table shows metadata about disks on the system. It required the FILE privilege.
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
disksDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
The WSREP_INFO plugin adds the WSREP_MEMBERSHIP and WSREP_STATUS tables to the Information Schema, providing detailed insights into Galera Cluster membership and status.
The WSREP_INFO plugin library contains the following plugins:
WSREP_MEMBERSHIP
WSREP_STATUS
The WSREP_MEMBERSHIP plugin creates the
The named_pipe authentication plugin allows Windows users connecting via named pipes to authenticate using their operating system credentials without a password.
The named_pipe authentication plugin allows the user to use operating system credentials when connecting to MariaDB via named pipe on Windows. Named pipe connections are enabled by the system variable.
The named_pipe authentication plugin works by using and calling GetUserName() to retrieve the user name of the process that is connected to the named pipe. Once it has the user name, it authenticates the connecting user as the MariaDB account that has the same user name.
SELECT plugin_name, plugin_version, plugin_maturity
FROM information_schema.plugins
ORDER BY plugin_name;SET old_passwords=0;
CREATE USER username@hostname IDENTIFIED BY 'mariadb';SET old_passwords=0;
GRANT SELECT ON db.* TO username@hostname IDENTIFIED BY 'mariadb';SET old_passwords=0;
SELECT PASSWORD('mariadb');
+-------------------------------------------+
| PASSWORD('mariadb') |
+-------------------------------------------+
| *54958E764CE10E50764C2EECBB71D01F08549980 |
+-------------------------------------------+
CREATE USER username@hostname
IDENTIFIED BY PASSWORD '*54958E764CE10E50764C2EECBB71D01F08549980';CREATE USER username@hostname
IDENTIFIED VIA mysql_native_password USING '*54958E764CE10E50764C2EECBB71D01F08549980';SET PASSWORD = PASSWORD('new_secret')SET old_passwords=0;
ALTER USER username@hostname IDENTIFIED BY 'new_secret';mysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=aliceINSTALL SONAME 'simple_password_check';[mariadb]
...
plugin_load_add = simple_password_checkUNINSTALL SONAME 'simple_password_check';SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('abc');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsALTER USER user_name IDENTIFIED WITH mysql_native_password BY 'new_password'mysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=aliceconcat('P', conv(log2(iterations)-10, 10, 62), ':', base64(salt), ':', base64(hash))INSTALL SONAME 'auth_parsec';CREATE USER test1@'%' IDENTIFIED VIA parsec USING PASSWORD('pwd');SET old_passwords=1;
CREATE USER username@hostname IDENTIFIED BY 'mariadb';SET old_passwords=1;
GRANT SELECT ON db.* TO username@hostname IDENTIFIED BY 'mariadb';SET old_passwords=1;
Query OK, 0 rows affected (0.000 sec)
SELECT PASSWORD('mariadb');
+---------------------+
| PASSWORD('mariadb') |
+---------------------+
| 021bec665bf663f1 |
+---------------------+
1 row in set (0.000 sec)
CREATE USER username@hostname IDENTIFIED BY PASSWORD '021bec665bf663f1';
Query OK, 0 rows affected (0.000 sec)CREATE USER username@hostname IDENTIFIED VIA mysql_old_password USING '021bec665bf663f1';
Query OK, 0 rows affected (0.000 sec)SET PASSWORD = PASSWORD('new_secret')SET old_passwords=1;
ALTER USER username@hostname IDENTIFIED BY 'new_secret';mysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice[timestamp],[serverhost],[username],[host],[connectionid],0,CONNECT,[database],,0
[timestamp],[serverhost],[username],[host],[connectionid],0,DISCONNECT,,,0
[timestamp],[serverhost],[username],[host],[connectionid],0,FAILED_CONNECT,,,[retcode][timestamp],[serverhost],[username],[host],[connectionid],[queryid],QUERY,[database],[object], [retcode][timestamp],[serverhost],[username],[host],[connectionid],[queryid],CREATE,[database],[object],
[timestamp],[serverhost],[username],[host],[connectionid],[queryid],READ,[database],[object],
[timestamp],[serverhost],[username],[host],[connectionid],[queryid],WRITE,[database],[object],
[timestamp],[serverhost],[username],[host],[connectionid],[queryid],ALTER,[database],[object],
[timestamp],[serverhost],[username],[host],[connectionid],[queryid],RENAME,[database],
[object_old]|[database_new].[object_new],
[timestamp],[serverhost],[username],[host],[connectionid],[queryid],DROP,[database],[object],ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --disks=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
1.1
Stable
, , ,
1.0
Beta
, ,
The WSREP_STATUS plugin creates the WSREP_STATUS table in the INFORMATION_SCHEMA database. The plugin also adds the SHOW WSREP_STATUS statement.
These tables and statements provide information about Galera. Only users with the SUPER privilege can access this information.
iAlthough the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
Description: Controls how the server treats the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --wsrep-membership=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
Description: Controls how the server treats the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --wsrep-status=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
This page is licensed: CC BY-SA / Gnu FDL
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
To create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause:
If SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:
The named_pipe authentication plugin does not require any specific client authentication plugins. It should work with all clients.
The named_pipe authentication plugin does not require any special support in client libraries. It should work with all client libraries.
In this example, a user wlad is already logged into the system. Because he has identified himself to the operating system, he does not need to do it again for the database — MariaDB trusts the operating system credentials. However, he cannot connect to the database as another user.
Description: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
There may be ambiguity between this option and the system variable. See about that.
Command line: --named-pipe=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
Introduced: MariaDB 10.1.11
This page is licensed: CC BY-SA / Gnu FDL
The Password Reuse Check Plugin prevents users from reusing previous passwords, with a retention policy controlled by the password_reuse_check_interval variable.
The plugin is used to prevent a user from reusing a password, which can be a requirement in some security policies. The system variable determines the retention period, in days, for a password. By default, this is zero, meaning unlimited retention. Old passwords are stored in the .
Note that passwords can be directly set as a hash, bypassing the password validation, if the variable is OFF (it is ON by default).
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default.
You can install the plugin dynamically, without restarting the server, by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
The bump to version 2.0 required the change of the stored format to mitigate an implementation weakness () and as such the bump from 1.0 to 2.0 will invalidate previously saved password reuse protections.
(MariaDB Foundation blog post)
This page is licensed: CC BY-SA / Gnu FDL
This guide shows how to authenticate database users using local Unix accounts and map Unix groups to MariaDB users with the PAM plugin.
We walk through the configuration of PAM authentication using the pam authentication plugin and user and group mapping with the pam_user_map PAM module. The primary authentication will be handled by the pam_unix PAM module, which performs standard Unix password authentication.
In this walkthrough, we are going to assume the following hypothetical requirements:
The Unix user foo should be mapped to the MariaDB user bar. (foo: bar)
Any Unix user in the Unix group dba should be mapped to the MariaDB user dba. (@dba: dba)
Let's go ahead and create the Unix users and groups that we are using for this hypothetical scenario.
First, let's create the foo user and a couple users to go into the dba group. Note that each of these users needs a password.
Next, let's create the dba group and add our two users to it:
We also need to create Unix users with the same name as the bar and dba MariaDB users. See to read more about why. No one will be logging in as these users, so they do not need passwords.
Next, let's .
Before the module can be compiled from source, we may need to install some dependencies.
On RHEL, CentOS, and other similar Linux distributions that use , we need to install gcc and pam-devel:
On Debian, Ubuntu, and other similar Linux distributions that use , we need to install gcc and libpam0g-dev:
And then we can build and install the library with the following:
Next, let's based on our hypothetical requirements.
The configuration file for the pam_user_map PAM module is /etc/security/user_map.conf. Based on our hypothetical requirements, ours would look like:
Next, let's .
Log into the MariaDB Server and execute the following:
Next, let's . We will call our service mariadb, so our PAM service configuration file will be located at /etc/pam.d/mariadb on most systems.
Since we are only doing Unix authentication with the pam_unix PAM module and group mapping with the pam_user_map PAM module, our configuration file would look like this:
The pam_unix PAM module adds on a lot of systems. We basically have to give the user that runs mysqld access to /etc/shadow.
If the mysql user is running mysqld, then we can do that by executing the following:
The server needs to be restarted for this change to take affect.
Next, let's . Remember that our PAM service is called mariadb.
First, let's create the MariaDB user for the user mapping: foo: bar . This means we need to create a bar user:
Next, let's create the MariaDB user for the group mapping: @dba: dba . This means that we need to create a dba user:
Next, to allow for the user and group mapping, we need to that is also able to PROXY as the bar and dba users. Before we can create the proxy user, we might need to :
Finally, let's create the anonymous proxy user:
Next, let's test out our configuration by . We can verify this by logging in as each of our users and comparing the return value of , which is the original user name and the return value of , which is the authenticated user name.
First, let's test our foo user:
We can verify that our foo Unix user was properly mapped to the bar MariaDB user by looking at the return value of CURRENT_USER().
Next, let's test our alice user in the dba group:
Finally, let's test our bob user in the dba group:
We can verify that our alice and bob Unix users in the dba Unix group were properly mapped to the dba MariaDB user by looking at the return values of CURRENT_USER().
This page is licensed: CC BY-SA / Gnu FDL
The ed25519 authentication plugin provides high-security password authentication using the Elliptic Curve Digital Signature Algorithm, a modern alternative to SHA-1.
MySQL has used SHA-1 based authentication since version 4.1. The authentication plugin is called . Over the years as computers became faster, new attacks on SHA-1 were being developed. Nowadays SHA-1 is no longer considered as secure as it was in 2001. That's why the ed25519 authentication plugin was created.
The ed25519 authentication plugin uses to securely store users' passwords and to authenticate users. The algorithm is the same one that is . It is based on the elliptic curve and code created by .
INSTALL SONAME 'disks';[mariadb]
...
plugin_load_add = disksUNINSTALL SONAME 'disks';SELECT * FROM information_schema.DISKS;
+-----------+-------+----------+---------+-----------+
| Disk | Path | Total | Used | Available |
+-----------+-------+----------+---------+-----------+
| /dev/vda1 | / | 26203116 | 2178424 | 24024692 |
| /dev/vda1 | /boot | 26203116 | 2178424 | 24024692 |
| /dev/vda1 | /etc | 26203116 | 2178424 | 24024692 |
+-----------+-------+----------+---------+-----------+INSTALL SONAME 'wsrep_info';[mariadb]
...
plugin_load_add = wsrep_infoUNINSTALL SONAME 'wsrep_info';SHOW TABLES FROM information_schema LIKE 'WSREP%';
+---------------------------------------+
| Tables_in_information_schema (WSREP%) |
+---------------------------------------+
| WSREP_STATUS |
| WSREP_MEMBERSHIP |
+---------------------------------------+INSTALL SONAME 'auth_named_pipe';[mariadb]
...
plugin_load_add = auth_named_pipeUNINSTALL SONAME 'auth_named_pipe';CREATE USER username@hostname IDENTIFIED VIA named_pipe;GRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA named_pipe;CREATE USER wlad IDENTIFIED VIA named_pipe;
CREATE USER monty IDENTIFIED VIA named_pipe;
quit
C:\>echo %USERNAME%
wlad
C:\> mysql --user=wlad --protocol=PIPE
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.12-MariaDB-debug Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> quit
Bye
C:\> mysql --user=monty --protocol=PIPE
ERROR 1698 (28000): Access denied for user 'monty'@'localhost'sudo useradd foo
sudo passwd foo
sudo useradd alice
sudo passwd alice
sudo useradd bob
sudo passwd bobsudo groupadd dba
sudo usermod -a -G dba alice
sudo usermod -a -G dba bobsudo useradd bar
sudo useradd dba -g dbasudo yum install gcc pam-develsudo apt-get install gcc libpam0g-devwget https://raw.githubusercontent.com/MariaDB/server/10.4/plugin/auth_pam/mapper/pam_user_map.c
gcc pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so
sudo install --mode=0755 pam_user_map.so /lib64/security/foo: bar
@dba:dbaINSTALL SONAME 'auth_pam';auth required pam_unix.so audit
auth required pam_user_map.so
account required pam_unix.so auditsudo groupadd shadow
sudo usermod -a -G shadow mysql
sudo chown root:shadow /etc/shadow
sudo chmod g+r /etc/shadowCREATE USER 'bar'@'%' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON *.* TO 'bar'@'%' ;CREATE USER 'dba'@'%' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'%' ;DELETE FROM mysql.db WHERE User='' AND Host='%';
FLUSH PRIVILEGES;CREATE USER ''@'%' IDENTIFIED VIA pam USING 'mariadb';
GRANT PROXY ON 'bar'@'%' TO ''@'%';
GRANT PROXY ON 'dba'@'%' TO ''@'%';$ mysql -u foo -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+------------------------------------------------+----------------+
| foo@ip-172-30-0-198.us-west-2.compute.internal | bar@% |
+------------------------------------------------+----------------+
1 row in set (0.000 sec)$ mysql -u alice -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+--------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+--------------------------------------------------+----------------+
| alice@ip-172-30-0-198.us-west-2.compute.internal | dba@% |
+--------------------------------------------------+----------------+
1 row in set (0.000 sec)$ mysql -u bob -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+------------------------------------------------+----------------+
| bob@ip-172-30-0-198.us-west-2.compute.internal | dba@% |
+------------------------------------------------+----------------+
1 row in set (0.000 sec)Although the plugin's shared library is distributed by default with MariaDB, with a file name of auth_ed25519.so (Unix) or auth_ed25519.dll (Windows), the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, those options must be removed to prevent the plugin from being loaded the next time the server is restarted.
You can create a user account by executing the CREATE USER statement and providing the IDENTIFIED VIA clause followied by the name of the plugin, ed25519, and providing the USING clause followed by the PASSWORD() function, with the plain-text password as an argument:
If SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:
The PASSWORD() function and SET PASSWORD statements don't work with the ed25519 authentication plugin. Instead, you have to use the UDF that comes with the authentication plugin to calculate the password hash:
Now you can calculate a password hash by executing this query:
Now you can use it to create the user account using the new password hash. As with any password, you should always use a complex password that isn't easy to guess. If you don't, if anyone gets access to the stored passwords in the mysql.user table, they could use rainbow tables to figure out the original password.
To create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause while providing the password hash as the USING clause:
Note that users require a password in order to be able to connect. It is possible to create users without specifying a password, but they will be unable to connect.
You can change a user account's password by executing the SET PASSWORD statement followed by the PASSWORD() function and providing the plain-text password as an argument:
You can also change the user account's password with the ALTER USER statement. You would have to specify the name of the plugin in the IDENTIFIED VIA clause while providing the plain-text password as an argument to the PASSWORD() function in the USING clause:
The PASSWORD() function and SET PASSWORD statement did not work with the ed25519 authentication plugin. Instead, you would have to use the UDF that comes with the authentication plugin to calculate the password hash:
Now you can calculate a password hash by executing this query:
Now you can change the user account's password using the new password hash.
You can change the user account's password with the ALTER USER statement. You have to specify the name of the plugin in the IDENTIFIED VIA clause, while providing the password hash as the USING clause:
For clients that use the libmysqlclient or libraries, MariaDB provides one client authentication plugin that is compatible with the ed25519 authentication plugin:
client_ed25519
When connecting with a client or utility to a server as a user account that authenticates with the ed25519 authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:
The client_ed25519 client authentication plugin hashes and signs the password using the Elliptic Curve Digital Signature Algorithm (ECDSA) before sending it to the server.
supports ed25519 authentication using the client authentication plugins mentioned in the previous section.
supports ed25519 authentication using the client authentication plugins mentioned in the previous section.
supports ed25519 authentication.
supports ed25519 authentication.
supports ed25519 authentication.
The connector implemented support for this authentication plugin in a separate NuGet package called MySqlConnector.Authentication.Ed25519. After the package is installed, your application must call Ed25519AuthenticationPlugin.Install to enable it.
Description: Controls how the server should treat the plugin when it starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --ed25519=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
This page is licensed: CC BY-SA / Gnu FDL
1.0
Alpha
1.0
Beta
1.0
Gamma
2.0
Stable
, , ,
The pam_user_map PAM module allows administrators to map external PAM users and groups to specific MariaDB accounts for flexible authorization management.
Even when using the pam authentication plugin, the authenticating PAM user account still needs to exist in MariaDB, and the account needs to have privileges in the database. Creating these MariaDB accounts and making sure the privileges are correct can be a lot of work. To decrease the amount of work involved, some users would like to be able to map a PAM user to a different MariaDB user. For example, let’s say that alice and bob are both DBAs. It would be nice if each of them could log into MariaDB with their own PAM username and password, while MariaDB sees both of them as the same dba user. That way, there is only one MariaDB account to keep track of.
Although most PAM modules usually do not do things like this, PAM supports the ability to change the user name in the process of authentication.The MariaDB pam authentication plugin fully supports this feature of PAM.
Rather than building user and group mapping into the pam authentication plugin, MariaDB thought that it would cover the most use cases and offer the most flexibility to offload this functionality to an external PAM module. The pam_user_map PAM module was implemented by MariaDB to facilitate this. This PAM module can be used by the pam authentication plugin, just like other PAM modules.
Unlike MariaDB, MySQL and Percona implemented group mapping in their PAM authentication plugins. If you've read through or , you've probably seen syntax where the group mappings are provided in the statement like this:
Since MariaDB's user and group mapping is performed by an external PAM module, MariaDB's pam authentication plugin does not support this syntax. Instead, the user and group mappings for the pam_user_map PAM module are configured in an external configuration file. This is discussed in a later section.
The pam_user_map PAM module gets installed as part of all our MariaDB server packages.
Some Linux distributions have not picked up this change in their own packages yet. When using such an installation, it may be necessary to compile the PAM module from source as described in the next section, or to manually extract it from one of our server packages and copy it to the target system.
Installing Compilation Dependencies
Before the module can be compiled from source, you may need to install some dependencies.
On RHEL, CentOS, and other similar Linux distributions that use , you need to install gcc, pam-devel and MariaDB-devel:
On Debian, Ubuntu, and other similar Linux distributions that use , you need to install gcc, libpam0g-dev:
Compiling and Installing the pam_user_map PAM Module
The pam_user_map PAM module can be built by downloading plugin/auth_pam/mapper/pam_user_map.c file from the MariaDB source tree and compiling it after minor adjustments. Once it is built, it can be installed to the system's PAM module directory, which is typically /lib64/security/:
You also need to adjust the major version number in the URL on the first line to match your installed MariaDB version, and the #-I include path argument on the gcc line, as depending on operating system and MariaDB server version, the plugin_auth_common.h file may be installed in a directory other than /usr/include/mysql/ .
The pam_user_map PAM module uses the configuration file at the path /etc/security/user_map.conf to determine its user and group mappings. The file's format is described below.
To map a specific PAM user to a specific MariaDB user:
Or to map any PAM user in a specific PAM group to a specific MariaDB user, the group name is prefixed with @:
For example, here is an example /etc/security/user_map.conf:
With user and group mapping, configuring PAM is done similar to how it is . However, when configuring the PAM service, you will have to add an auth line for the pam_user_map PAM module to the service's PAM configuration file:
With user and group mapping, creating users is done similar to how it is . However, one major difference is that you will need to the privilege on the mapped user to the original user.
Consider having the following configured in /etc/security/user_map.conf:
Then you could execute the following to grant the relevant privileges:
Note that the ''@'%' account is a special catch-all . Any login by a user that has no more specific account match in the system will be matched by this anonymous account.
Also note that you might not be able to create the ''@'%' anonymous account by default on some systems without doing some extra steps first. See for more information.
In case any user mapping is performed, the original user name is returned by the SQL function , while the authenticated user name is returned by the SQL function . The latter actually defines what privileges are available to a connected user.
Consider having the following configured:
Then the following output would verify that it is working properly:
We can verify that our foo PAM user was properly mapped to the bar MariaDB user by looking at the return value of CURRENT_USER().
By default, the pam_user_map PAM module does not perform any logging. However, if you want to enable debug logging, then you can add the debug module argument to the service's PAM configuration file:
When debug logging is enabled, the pam_user_map PAM module will write log entries to the as other PAM modules, which is typically /var/log/secure on many systems.
For example, this debug log output can look like the following:
With user and group mapping, any PAM user or any PAM user in a given PAM group can be mapped to a specific MariaDB user account. However, due to the way PAM works, a PAM user with the same name as the mapped MariaDB user account must exist.
Consider the configuration file for the PAM service file containing the following:
Consider etc/security/user_map.conf containing the following:
In that case, any PAM user in the PAM group dba are mapped to the MariaDB user account dba. But if a PAM user with the name dba doesn't exist, the pam_user_map PAM module's debug logging writes errors to the syslog, like the following:
In the above log snippet, notice that both the pam_unix and the pam_sss PAM modules are complaining that the dba PAM user does not appear to exist, and that these complaints cause the PAM authentication process to fail, which causes the MariaDB authentication process to fail as well.
This can be fixed by creating a PAM user with the same name as the mapped MariaDB user account, which is dba in this case.
You may also be able to work around this problem by essentially disabling PAM's account verification for the service with the PAM module. For example, in the above case, that would be:
See for more information.
You may find the following PAM and user mapping-related tutorials helpful:
This page is licensed: CC BY-SA / Gnu FDL
The unix_socket plugin authenticates users connecting via the local Unix socket file by matching the operating system user ID to the database user account.
The unix_socket authentication plugin is installed by default, and it is used by the 'root'@'localhost' user account by default. See Authentication for more information.
The unix_socket authentication plugin allows the user to use operating system credentials when connecting to MariaDB via the local Unix socket file. This Unix socket file is defined by the socket system variable.
The unix_socket authentication plugin works by calling the getsockopt system call with the SO_PEERCRED socket option, which allows it to retrieve the uid of the process that is connected to the socket. It is then able to get the user name associated with that uid. Once it has the user name, it will authenticate the connecting user as the MariaDB account that has the same user name.
The unix_socket authentication plugin is not suited to multiple Unix users accessing a single MariaDB user account.
A unix_socket authentication plugin is a passwordless security mechanism. Its security lies in the strength of the access to the Unix user, rather than the complexity and the secrecy of the password.
As security differs from password security, the strengths and weaknesses need to be considered, and those can differ depending on the specific installation.
Access is limited to the Unix user so, for example, a www-data user cannot access root with the unix_socket authentication plugin.
There is no password which can be cracked by brute force.
There is no password that can be accidentally exposed by user accident, poor security on backups, or poor security on passwords in configuration files.
The strength of a unix_socket authentication plugin is effectively the strength of the security of the Unix users on the system. In most cases, the Unix user default installation is sufficiently secure. However, the following is a non-exhaustive list of potential Unix user security issues that may arise.
Common access areas without screen locks, where an unauthorized user accesses the logged in Unix user of an authorized user.
Extensive sudo access grants that provide users with access to execute commands of a different Unix user.
Scripts writable by Unix users other than the Unix user that are executed (via cron or directly) by the Unix user.
Web pages that are susceptible to command injection, where the Unix user running the web page has elevated privileges in the database that weren't intended to be used.
In some of these scenarios a database password may prevent these security exploits, however it will remove all the strengths of the unix_socket authentication plugin previously mentioned.
The unix_socket authentication plugin is installed by default.
If you do not want it to be available by default, you must disable it.
The unix_socket authentication plugin is also installed by default in new installations that use the packages provided by Debian's default repositories and Ubuntu's default repositories. See for more information.
The unix_socket authentication plugin can be disabled by starting the server with the option set to OFF. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
As an alternative, the option can also be set to OFF by pairing the option with the disable :
The unix_socket authentication plugin is installed by default in almost all MariaDB server versions. If you work with a version that doesn't have the plugin installed, you can install it as described in one of the following ways.
Install the plugin without restarting the server. You can install the plugin dynamically, by executing or :
Instruct the server to load the plugin at startup. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a server in an , those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
To create a user account via , specify the name of the plugin in the clause:
If does not have NO_AUTO_CREATE_USER set, then you can also create the user account via :
The authentication string (if present) is compared with the socket's user name. Authentication proceeds if there's a match. In this case, the system variable contains the OS user.
Consider an OS user named 'bob' that has been created like this:
That user can connect like this:
Alternatively, accessing the sock file directly, the user can connect like this:
Once connected, you can view that user like this:
The plugin only checks whether the OS socket user id matches the MariaDB user name. It ignores the authentication string.
If Unix socket authentication does not meet your needs, you can switch a user account back to password-based authentication, by telling MariaDB to use a different for the account. The specific authentication plugin is specified with the clause. To switch to the authentication plugin, you need to do this:
If you use scripts that require passwordless access to MariaDB, this would cause them to break. You may be able to fix that by setting a password in the [client] in your /root/.my.cnf .
The unix_socket authentication plugin does not require any specific client authentication plugins. It should work with all clients.
The unix_socket authentication plugin does not require any special support in client libraries. It should work with all client libraries.
In this example, user serg is already logged into the operating system and has full shell access. The user has already authenticated with the operating system and the MariaDB account is configured to use the unix_socket authentication plugin, so there is no need to authenticate again for the database. MariaDB accepts the operating system credentials and allows the user to connect. However, any attempt to connect to the database as another operating system is denied.
unix_socketDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
The Cracklib Password Check Plugin enforces password strength by validating new passwords against the CrackLib library and its dictionary.
cracklib_password_check is a password validation plugin. It uses the CrackLib library to check the strength of new passwords. CrackLib is installed by default in many Linux distributions, since the system's Pluggable Authentication Module (PAM) authentication framework is usually configured to check the strength of new passwords with the pam_cracklib PAM module.
Note that passwords can be directly set as a hash, bypassing the password validation, if the strict_password_validation variable is OFF (it is ON by default).
The plugin requires at least cracklib 2.9.0, so it is not available on Debian/Ubuntu builds before Debian 8 Jessie/Ubuntu 14.04 Trusty, RedHat Enterprise Linux / CentOS 6.
The cracklib_password_check plugin's shared library is included in MariaDB packages as the cracklib_password_check.so or cracklib_password_check.dll shared library on systems where it can be built.
The cracklib_password_check plugin is included in systemd on Linux, but not in the older generic and glibc_214 tarballs.
The cracklib_password_check plugin can also be installed via a package manager on Linux. In order to do so, your system needs to be configured to install from one of the MariaDB repositories.
You can configure your package manager to install it from MariaDB Corporation's MariaDB Package Repository by using the .
You can also configure your package manager to install it from MariaDB Foundation's MariaDB Repository by using the .
Installing with yum/dnf
On RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using or . Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf:
Installing with apt-get
On Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using :
Installing with zypper
On SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using :
Once the shared library is in place, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
If password validation fails, then the original CrackLib error message can be viewed by executing .
When creating a new password, if the criteria are not met, the following error is returned:
When using the standard policy with the set to enforcing, mariadbd does not have access to /usr/share/cracklib, and you may see the following error when attempting to use the cracklib_password_check plugin:
And the SELinux audit.log contains errors like these:
This can be fixed by creating an SELinux policy that allows mysqld to load the CrackLib dictionary:
See for more information.
cracklib_password_check_dictionaryDescription: Sets the path to the CrackLib dictionary. If not set, the default CrackLib dictionary path is used. The parameter expects the base name of a cracklib dictionary (a set of three files with endings .hwm, .pwd, .pwi), not a directory path.
Command line: --cracklib-password-check-dictionary=value
Scope: Global
cracklib_password_checkDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
- permits the setting of basic criteria for passwords
This page is licensed: CC BY-SA / Gnu FDL
Manage your audit log files effectively. Learn how to define the log file path, set size limits, and configure rotation strategies to prevent log files from consuming all available disk space.
Logs can be written to a separate file or to the system logs. If you prefer to have the logging separated from other system information, the value of the variable server_audit_output_type should be set to file. Incidentally, file is the only option on Windows systems.
You can force a rotation by enabling the server_audit_file_rotate_now variable like so:
SET GLOBAL server_audit_file_rotate_now = ON;In addition to setting server_audit_output_type, you will have to provide the file path and name of the audit file. This is set in the variable . You can set the file size limit of the log file with the variable
So, if rotation is on and the log file has reached the size limit you set, a copy is created with a consecutive number as extension the original file will be truncated to be used for the auditing again. To limit the number of log files created, set the variable You can force log file rotation by setting the variable to a value of ON. When the number of files permitted is reached, the oldest file will be overwritten. Here is how those variables might be set in a :
For security reasons, it's better sometimes to use the system logs instead of a local file owned by the mysql user. To do this, the value of needs to be set to syslog. Advanced configurations, such as using a remote syslogd service, are part of the syslogd configuration.
The variables, and can be used to identify a system log entry made by the audit plugin. If a remote syslogd service is used for several MariaDB servers, these same variables are also used to identify the MariaDB server.
Here is a system log entry taken from a server which had set to the default value of mysql-server_auditing, and set to <prod1>.
Although the default values for and should be sufficient in most cases. They can be changed based on the definition in syslog.h for the functions openlog() and syslog().
This page is licensed: CC BY-SA / Gnu FDL
Control where and how the audit data is stored. This section explains how to direct output to a file or the system syslog, and how to configure logging parameters for different environments.
Events that are logged by the MariaDB Audit Plugin are grouped generally into different types: connect, query, and table events. To log based on these types of events, set the variable, to CONNECT, QUERY, or TABLE. To have the Audit Plugin log more than one type of event, put them in a comma-separated list like so:
You can put the equivalent of this in the configuration file like so:
By default, logging is set to OFF. To enable it, set the variable to ON. Note that if the is enabled, and a query is returned from the query cache, no TABLE records will appear in the log since the server didn't open or access any tables and instead relied on the cached results. So you may want to disable query caching.
The Feedback plugin collects and sends anonymous server usage and configuration data to MariaDB to help improve the software.
The feedback plugin is designed to collect and, optionally, upload
configuration and usage information to or to any other configured URL.
See the page on MariaDB.org to see collected MariaDB usage statistics.
MariaDB is usually distributed with this plugin included, but it is not enabled by default. On Windows, this plugin is part of the server and has a special checkbox in the installer window. Either way, you need to explicitly install and enable it in order for feedback data to be sent.
INSTALL SONAME 'auth_ed25519';[mariadb]
...
plugin_load_add = auth_ed25519UNINSTALL SONAME 'auth_ed25519';CREATE USER username@hostname IDENTIFIED VIA ed25519 USING PASSWORD('secret');GRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA ed25519 USING PASSWORD('secret');CREATE FUNCTION ed25519_password RETURNS STRING SONAME "auth_ed25519.so";SELECT ed25519_password("secret");
+---------------------------------------------+
| SELECT ed25519_password("secret"); |
+---------------------------------------------+
| ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY |
+---------------------------------------------+CREATE USER username@hostname IDENTIFIED VIA ed25519
USING 'ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY';GRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA ed25519
USING 'ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY';SET PASSWORD = PASSWORD('new_secret')ALTER USER username@hostname IDENTIFIED VIA ed25519 USING PASSWORD('new_secret');CREATE FUNCTION ed25519_password RETURNS STRING SONAME "auth_ed25519.so";SELECT ed25519_password("secret");
+---------------------------------------------+
| SELECT ed25519_password("secret"); |
+---------------------------------------------+
| ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY |
+---------------------------------------------+ALTER USER username@hostname IDENTIFIED VIA ed25519
USING 'ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY';mysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=aliceINSTALL SONAME 'password_reuse_check';[mariadb]
...
plugin_load_add = password_reuse_checkUNINSTALL SONAME 'password_reuse_check';INSTALL SONAME 'password_reuse_check';
GRANT SELECT ON *.* TO user1@localhost identified by 'pwd1';
Query OK, 0 rows affected (0.038 sec)
GRANT SELECT ON *.* TO user1@localhost identified by 'pwd1';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
GRANT SELECT ON *.* TO user1@localhost identified by 'pwd2';
Query OK, 0 rows affected (0.003 sec)
GRANT SELECT ON *.* TO user1@localhost identified by 'pwd1';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsDefault Unix user security is usually strong on preventing remote access and password brute force attempts.
Poor Unix user password practices including weak user passwords, password exposure and password reuse accompanied by an access vulnerability/mechanism of an unauthorized user to exploit this weakness.
Weak remote access mechanisms and network file system privileges.
Poor user security behavior including running untrusted scripts and software.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --unix-socket=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
Dynamic: No
Data Type: string
Default Value: Depends on the system. Often /usr/share/cracklib/pw_dict
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --cracklib-password-check=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
CREATE USER ''@''
IDENTIFIED WITH authentication_pam
AS 'mysql, root=developer, users=data_entry';sudo yum install gcc pam-devel MariaDB-develsudo apt-get install gcc libpam0g-dev libmariadb-devwget https://raw.githubusercontent.com/MariaDB/server/10.4/plugin/auth_pam/mapper/pam_user_map.c
sed -ie 's/config_auth_pam/plugin_auth_common/' pam_user_map.c
gcc -I/usr/include/mysql/ pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so
sudo install --mode=0755 pam_user_map.so /lib64/security/orig_pam_user_name: mapped_mariadb_user_name@orig_pam_group_name: mapped_mariadb_user_name=========================================================
#comments and empty lines are ignored
john: jack
bob: admin
top: accounting
@group_ro: readonlyauth required pam_unix.so audit
auth required pam_user_map.so
account required pam_unix.so auditfoo: bar
@dba:dbaCREATE USER 'bar'@'%' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON *.* TO 'bar'@'%' ;
CREATE USER 'dba'@'%' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'%' ;
CREATE USER ''@'%' IDENTIFIED VIA pam USING 'mariadb';
GRANT PROXY ON 'bar'@'%' TO ''@'%';
GRANT PROXY ON 'dba'@'%' TO ''@'%';foo: bar$ mysql -u foo -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+------------------------------------------------+----------------+
| foo@ip-172-30-0-198.us-west-2.compute.internal | bar@% |
+------------------------------------------------+----------------+
1 row in set (0.000 sec)auth required pam_unix.so audit
auth required pam_user_map.so debug
account required pam_unix.so auditJan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Opening file '/etc/security/user_map.conf'.
Jan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Incoming username 'alice'.
Jan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User belongs to 2 groups [alice,dba].
Jan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if user is in group 'dba': YES
Jan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User mapped as 'dba'
Jan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Opening file '/etc/security/user_map.conf'.
Jan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Incoming username 'bob'.
Jan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User belongs to 2 groups [bob,dba].
Jan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if user is in group 'dba': YES
Jan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User mapped as 'dba'
Jan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Opening file '/etc/security/user_map.conf'.
Jan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Incoming username 'foo'.
Jan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User belongs to 1 group [foo].
Jan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if user is in group 'dba': NO
Jan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if username 'foo': YES
Jan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User mapped as 'bar'auth required pam_sss.so
auth required pam_user_map.so debug
account sufficient pam_unix.so
account sufficient pam_sss.so@dba: dbaSep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Opening file '/etc/security/user_map.conf'.
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Incoming username 'alice'.
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): User belongs to 4 groups [dba,mongod,mongodba,mysql].
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Check if user is in group 'mysql': YES
Sep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): User mapped as 'dba'
Sep 27 17:17:05 dbserver1 mysqld: pam_unix(mysql:account): could not identify user (from getpwnam(dba))
Sep 27 17:17:05 dbserver1 mysqld: pam_sss(mysql:account): Access denied for user dba: 10 (User not known to the underlying authentication module)
Sep 27 17:17:05 dbserver1 mysqld: 2018-09-27 17:17:05 72 [Warning] Access denied for user 'alice'@'localhost' (using password: NO)auth required pam_sss.so
auth required pam_user_map.so debug
account required pam_permit.so[mariadb]
...
unix_socket=OFF[mariadb]
...
disable_unix_socketINSTALL SONAME 'auth_socket';[mariadb]
...
plugin_load_add = auth_socketUNINSTALL SONAME 'auth_socket';CREATE USER username@hostname IDENTIFIED VIA unix_socket;GRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA unix_socket;CREATE USER A identified via unix_socket as 'bob';
mariadb -uAmariadb -uA -S /var/run/mysqld/mysqld.sockSELECT USER(),@@external_user;
+-------------+-----------------+
| user() | @@external_user |
+-------------+-----------------+
| A@localhost | bob |
+-------------+-----------------+ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
SET PASSWORD = PASSWORD('foo');[client]
password=foo$ mysql -uroot
MariaDB []> CREATE USER serg IDENTIFIED VIA unix_socket;
MariaDB []> CREATE USER monty IDENTIFIED VIA unix_socket;
MariaDB []> quit
Bye
$ whoami
serg
$ mysql --user=serg
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.2.0-MariaDB-alpha-debug Source distribution
MariaDB []> quit
Bye
$ mysql --user=monty
ERROR 1045 (28000): Access denied for user 'monty'@'localhost' (using password: NO)sudo yum install MariaDB-cracklib-password-checksudo apt-get install mariadb-plugin-cracklib-password-checksudo zypper install MariaDB-cracklib-password-checkINSTALL SONAME 'cracklib_password_check';[mariadb]
...
plugin_load_add = cracklib_password_checkUNINSTALL SONAME 'cracklib_password_check';SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('abc');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsCREATE USER `user`@`hostname` IDENTIFIED BY 's0mePwd123.';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
SHOW WARNINGS;
+---------+------+----------------------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------------------+
| Warning | 1819 | cracklib: error loading dictionary |
| Error | 1819 | Your password does not satisfy the current policy requirements |
| Error | 1396 | Operation CREATE USER failed for 'user'@'hostname' |
+---------+------+----------------------------------------------------------------+type=AVC msg=audit(1548371977.821:66): avc: denied { read } for pid=3537 comm="mysqld" name="pw_dict.pwd" dev="xvda2" ino=564747 scontext=system_u:system_r:mysqld_t:s0 tcontext=system_u:object_r:crack_db_t:s0 tclass=file
type=SYSCALL msg=audit(1548371977.821:66): arch=c000003e syscall=2 success=no exit=-13 a0=7fdd2a674580 a1=0 a2=1b6 a3=1b items=0 ppid=1 pid=3537 auid=4294967295 uid=995 gid=992 euid=995 suid=995 fsuid=995 egid=992 sgid=992 fsgid=992 tty=(none) ses=4294967295 comm="mysqld" exe="/usr/sbin/mysqld" subj=system_u:system_r:mysqld_t:s0 key=(null)cd /usr/share/mysql/policy/selinux/
tee ./mariadb-plugin-cracklib-password-check.te <<EOF
module mariadb-plugin-cracklib-password-check 1.0;
require {
type mysqld_t;
type crack_db_t;
class file { execute setattr read create getattr execute_no_trans write ioctl open append unlink };
class dir { write search getattr add_name read remove_name open };
}
allow mysqld_t crack_db_t:dir { search read open };
allow mysqld_t crack_db_t:file { getattr read open };
EOF
sudo yum install selinux-policy-devel
make -f /usr/share/selinux/devel/Makefile mariadb-plugin-cracklib-password-check.pp
sudo semodule -i mariadb-plugin-cracklib-password-check.pp[mysqld]
...
server_audit_file_rotate_now=ON
server_audit_file_rotate_size=1000000
server_audit_file_rotations=5
...Aug 717:19:58localhostmysql-server_auditing:
<prod1> localhost.localdomain,root,localhost,1,7,
QUERY, mysql, 'SELECT * FROM user',0There are a few types of events that may be logged, not just the three common ones mentioned above. A full list of related system variables is detailed on the Server_Audit System Variables page, and status variables on the Server_Audit System Variables page of this documentation. Some of the major ones are highlighted below:
CONNECT
Connects, disconnects and failed connects—including the error code.
QUERY
Queries executed and their results in plain text, including failed queries due to syntax or permission errors.
TABLE
Tables affected by query execution.
QUERY_DDL
Similar to QUERY, but filters only DDL-type queries (CREATE, ALTER, DROP, RENAME and TRUNCATE). There are some exceptions however. RENAME USER is not logged, while CREATE/DROP [PROCEDURE / FUNCTION / USER] are logged.
QUERY_DML
Similar to QUERY, but filters only DML-type queries (DO, CALL, LOAD DATA/XML, DELETE, INSERT, SELECT, UPDATE, HANDLER , and REPLACE statements).
QUERY_DML_NO_SELECT
Similar to QUERY_DML, but doesn't log SELECT queries.
Since there are other types of queries besides DDL and DML, using the QUERY_DDL and QUERY_DML options together is not equivalent to using QUERY. There is the QUERY_DCL option for logging DCL types of queries (e.g., and GRANT``REVOKEstatements). In the same version, the server_audit_query_log_limit variable was added to be able to set the length of a log record. Previously, a log entry would be truncated due to long query strings.
If the Audit Plugin has been configured to log connect events, it will log connects, disconnects, and failed connects. For a failed connection, the log includes the error code.
It's possible to define a list of users for which events can be excluded or included for tracing their database activities. This list will be ignored, though, for the logging of connect events. This is because auditing standards distinguish between technical and physical users. Connects need to be logged for all types of users; access to objects needs to be logged only for physical users.
If QUERY, QUERY_DDL, QUERY_DML, QUERY_DML_NO_SELECT, and/or QUERY_DCL event types are enabled, then the corresponding types of queries that are executed will be logged for defined users. The queries will be logged exactly as they are executed, in plain text. This is a security vulnerability: anyone who has access to the log files will be able to read the queries. So make sure that only trusted users have access to the log files and that the files are in a protected location. An alternative is to use theTABLE event type instead of the query-related event types.
Queries are also logged if they cannot be executed or if they're unsuccessful. For example, a query will be logged because of a syntax error or because the user doesn't have the privileges necessary to access an object. These queries can be parsed by the error code that's provided in the log.
You may find failed queries to be more interesting: They can reveal problems with applications (e.g., an SQL statement in an application that doesn't match the current schema). They can also reveal if a malicious user is guessing at the names of tables and columns to try to get access to data.
Below is an example in which a user attempts to execute an UPDATE statement on a table for which he does not have permission:
Looking in the Audit Plugin log (server_audit.log) for this entry, you can see the following entry:
This log entry contains the date and time of the query, followed by the server host, and the user and host for the account.
Next is the connection and query identification numbers (i.e., 15 and 46). After the log event type (i.e., QUERY), the database name (i.e., company), the query, and the error number are recorded.
Notice that the last value in the log entry is 1142. That's the error number for the query. To find failed queries, you would look for two elements: the notation indicating that it's an entry QUERY and the last value for the entry. If the query is successful, the value will be0 .
Note that the QUERY event type will log queries that are not included in any of the subordinate QUERY_* event types, such as:
MariaDB has the ability to record table events in the logs—this is not a feature of MySQL. This feature is the only way to log which tables have been accessed through a view, a stored procedure, a stored function, or a trigger. Without this feature, a log entry for a query shows only the view, stored procedure or function used, not the underlying tables. Of course, you could create a custom application to parse each query executed to find the SQL statements used and the tables accessed, but that would be a drain on system resources. Table event logging is much simpler: it adds a line to the log for each table accessed, without any parsing. It includes notes as to whether it was a read or a write.
If you want to monitor user access to specific databases or tables (e.g., mysql.user), you can search the log for them. Then if you want to see a query which accessed a certain table, the audit log entry will include the query identification number. You can use it to search the same log for the query entry. This can be useful when searching a log containing tens of thousands of entries.
Because of the TABLE option, you may disable query logging and still know who accessed which tables. You might want to disable QUERY event logging to prevent sensitive data from being logged. Since table event logging will log who accessed which table, you can still watch for malicious activities with the log. This is often enough to fulfill auditing requirements.
Below is an example with both TABLE and QUERY events logging. For this scenario, suppose there is a VIEW in which columns are selected from a few tables in a company database. The underlying tables are related to sensitive employee information, in particular salaries. Although we may have taken precautions to ensure that only certain user accounts have access to those tables, we will monitor the Audit Plugin logs for anyone who queries them—directly or indirectly through a view.
Although the user executed only one SELECT statement, there are multiple entries to the log: one for each table accessed and one entry for the query on the view, (i.e., employee_pay). We know primarily this is all for one query because they all have the same connection and query identification numbers (i.e., 29 and 913).
The Audit Plugin will log the database activities of all users, or only the users that you specify. A database activity is defined as a query event or a table event. Connect events are logged for all users.
You may specify users to include in the log with the server_audit_incl_users variable or exclude users with the server_audit_excl_users variable. This can be useful if you would like to log entries, but are not interested in entries from trusted applications and would like to exclude them from the logs.
You would typically use either the server_audit_incl_users variable or the server_audit_excl_users variable. You may, though, use both variables. If a username is inadvertently listed in both variables, database activities for that user will be logged because server_audit_incl_users takes priority.
Although MariaDB considers a user as the combination of the username and hostname, the Audit Plugin logs only based on the username. MariaDB uses both the username and hostname so as to grant privileges relevant to the location of the user. Privileges are not relevant though for tracing the access to database objects. The host name is still recorded in the log, but logging is not determined based on that information.
The following example shows how to add a new username to the server_audit_incl_users variable without removing previous usernames:
Remember to add also any new users to be included in the logs to the same variable in MariaDB configuration file. Otherwise, when the server restarts it will discard the setting.
By default events from all users are logged, but certain users can be excluded from logging by using the server_audit_excl_users variable. For example, to exclude users valerianus and rocky from having their events logged:
This option is primarily used to exclude the activities of trusted applications.
Alternatively, server_audit_incl_users can be used to specifically include users. Both variables can be used, but if a user appears on both lists, server_audit_incl_users has a higher priority, and their activities will be logged.
This page is licensed: CC BY-SA / Gnu FDL
feedback plugin is installed and enabled, execute the SHOW PLUGINS statement or query the information_schema.plugins table:If that SELECT returns no rows, then you still need to install the plugin.
When the plugin is installed and enabled, you will see:
In some releases, the plugin's shared library is distributed with MariaDB by default, but the plugin is not actually installed by MariaDB. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
You can enable the plugin by setting the feedback option to ON in a relevant server option group in an option file:
In Windows, the plugin can also be enabled during a new MSI installation. The MSI GUI installation provides the "Enable feedback plugin" checkbox to enable the plugin. The MSI command-line installation provides the FEEDBACK=1 command-line option to enable the plugin.
See the next section for how to verify the plugin is installed and active and (if needed) install the plugin.
The feedback plugin collects the following data:
Certain rows from SHOW STATUS and SHOW VARIABLES.
All installed plugins and their versions.
System information such as CPU count, memory, architecture, and OS/linux distribution.
The feedback_server_uid, which is a SHA1 hash of the MAC address of the first network interface and the TCP port that the server listens on.
The feedback plugin creates the FEEDBACK table in the INFORMATION_SCHEMA database. To see the data that has been collected by the plugin, you can execute:
Only the contents of this table are sent to the feedback_url.
MariaDB stores collation usage statistics. Each collation that has been used by the server
will have a record in output of SELECT * FROM information_schema.feedback , for example:
Collations that have not been used will not be included in the result.
The feedback plugin sends the data using a POST request to any URL or a list of URLs
that you specify by setting the feedback_url system variable. By default, this is set to the following URL:
https://feedback.mariadb.org/rest/v1/post
Both HTTP and HTTPS protocols are supported.
If HTTP traffic requires a proxy in your environment, then you can specify the proxy by setting the feedback_http_proxy system variable.
If the feedback_url system variable is not set to an empty string, then the plugin will automatically send a report to all URLs in the list a few minutes after the server starts up and then once a week after that.
If the feedback_url system variable is set to an empty string, then the plugin will not automatically send any data. This may be necessary if outbound HTTP communication from your database server is not permitted. In this case, you can still upload the data manually, if you'd like.
First, generate the report file with the MariaDB command-line mariadb client:
Manual uploading allows you to be absolutely sure that we receive only the data shown in the INFORMATION_SCHEMA.FEEDBACK table and that no private or sensitive information is being sent.
Description: Proxy server for use when http calls cannot be made, such as in a firewall environment. The format is host:port.
Command line: --feedback-http=proxy=value
Read-only: Yes
Data Type: string
Default Value: '' (empty)
Description: Time in seconds before retrying if the plugin failed to send the data for any reason.
Command line: --feedback-send-retry-wait=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 60
Valid Values: 1 to 86400
Description: An attempt to send the data times out and fails after this many seconds.
Command line: --feedback-send-timeout=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 60
Valid Values: 1 to 86400
Description: Automatically calculated server unique id hash.
Scope: Global
Dynamic: No
Data Type: string
Description: URL to which the data is sent. More than one URL, separated by spaces, can be specified. Set it to an empty string to disable data sending.
Command line: --feedback-url=url
Scope: Global
Dynamic: No
Data Type: string
Default Value: https://feedback.mariadb.org/rest/v1/post
Description: The value of this option is not used by the plugin, but it is included in the feedback data. It can be used to add any user-specified string to the report. This could be used to help to identify it. For example, a support contract number, or a computer name (if you collect reports internally by specifying your own feedback-url).
Command line: --feedback-user-info=string
Scope: Global
Dynamic: No
Data Type: string
Default Value: Empty string
Description: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --feedback=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
This page is licensed: CC BY-SA / Gnu FDL
The Query Response Time plugin collects and displays the distribution of query execution times, helping to identify performance bottlenecks.
The query_response_time plugin creates the table in the database. The plugin also adds the and statements.
The provides exact information about queries that take a long time to execute. However, sometimes there are a large number of queries that each take a very short amount of time to execute. This feature provides a tool for analyzing that information by counting and displaying the number of queries according to the length of time they took to execute.
This feature is based on Percona's .
SET GLOBAL server_audit_events = 'CONNECT,QUERY,TABLE';[mysqld]
...
server_audit_events=connect,queryUPDATE employees
SET salary = salary * 1.2
WHERE emp_id = 18236;
ERROR 1142 (42000):
UPDATE command denied to user 'bob'@'localhost' for table 'employees'20170817 11:07:18,ip-172-30-0-38,bob,localhost,15,46,QUERY,company,'UPDATE employees SET salary = salary * 1.2 WHERE emp_id = 18236',114220170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,employees,
20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,employees_salaries,
20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,ref_job_titles,
20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,org_departments,
20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,QUERY,company,
'SELECT * FROM employee_pay WHERE title LIKE \'%Executive%\' OR title LIKE \'%Manager%\'',0SET GLOBAL server_audit_incl_users = CONCAT(@@global.server_audit_incl_users, ',Maria');server_audit_excl_users=valerianus,rockySELECT plugin_status FROM information_schema.plugins
WHERE plugin_name = 'feedback';
+---------------+
| plugin_status |
+---------------+
| DISABLED |
+---------------+SELECT plugin_status FROM information_schema.plugins
WHERE plugin_name = 'feedback';
+---------------+
| plugin_status |
+---------------+
| ACTIVE |
+---------------+INSTALL SONAME 'feedback';[mariadb]
...
plugin_load_add = feedbackUNINSTALL SONAME 'feedback';[mariadb]
...
feedback=ONSELECT * FROM information_schema.feedback;+----------------------------------------+---------------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+----------------------------------------+---------------------+
| Collation used utf8_unicode_ci | 10 |
| Collation used latin1_general_ci | 20 |
+----------------------------------------+---------------------+$ mariadb -e 'select * from information_schema.feedback' > report.txt$ curl -F data=@report.txt https://feedback.mariadb.org/rest/v1/postQUERY_DCL
Similar to QUERY, but filters only DCL-type queries (CREATE USER, DROP USER, RENAME USER, GRANT, REVOKE and SET PASSWORD statements).
This shared library actually consists of a number of different plugins:
QUERY_RESPONSE_TIME - An INFORMATION_SCHEMA plugin that exposes statistics.
QUERY_RESPONSE_TIME_AUDIT - audit plugin, collects statistics.
Both plugins need to be installed to get meaningful statistics.
In addition, these additional plugins are available:
QUERY_RESPONSE_TIME_READ
QUERY_RESPONSE_TIME_READ_WRITE
QUERY_RESPONSE_TIME_WRITE
This shared library actually consists of a number of different plugins:
QUERY_RESPONSE_TIME - An INFORMATION_SCHEMA plugin that exposes statistics.
QUERY_RESPONSE_TIME_AUDIT - audit plugin, collects statistics.
Both plugins need to be installed to get meaningful statistics.
Although the plugin's shared library is distributed with MariaDB by default, the plugins are not actually installed by MariaDB by default. There are two methods that can be used to install the plugins with MariaDB.
The first method can be used to install the plugin library without restarting the server. You can install the plugins dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin library when it starts up. The plugins can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:
Note that in both cases you have to activate data collection by changing the query_response_time_stats setting to ON, it is OFF by default even when the plugin library is loaded.
You can change the setting at runtime with
or in the options file after the plugin has been loaded:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
The user can define time intervals that divide the range 0 to positive infinity into smaller intervals and then collect the number of commands whose execution times fall into each of those intervals.
Each interval is described as:
The range_base is some positive number (see Limitations). The interval is defined as the difference between two nearby powers of the range base.
If the range base equals 10, we have the following intervals:
or
For each interval, a count is made of the queries with execution times that fell into that interval.
You can select the range of the intervals by changing the range base. For example, for base range=2 we have the following intervals:
or
Small numbers look strange (i.e., don’t look like powers of 2), because we lose precision on division when the ranges are calculated at runtime. In the resulting table, you look at the high boundary of the range:
This means there were:
You can get the distribution by querying the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database:
You can also write more complex queries:
Note: If query_response_time_stats is set to ON, then the execution times for these two SELECT queries will also be collected.
As an alternative to the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database, you can also use the SHOW QUERY_RESPONSE_TIME statement:
Flushing the plugin data does two things:
Clears the collected times from the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database.
Reads the value of query_response_time_range_base and uses it to set the range base for the table.
Plugin data can be flushed with the FLUSH QUERY_RESPONSE_TIME statement:
Setting the query_response_time_flush system variable has the same effect:
It is possible to specify flushing read and/or write statements with the FLUSH QUERY_RESPONSE_TIME_READ, FLUSH QUERY_RESPONSE_TIME_WRITE and FLUSH QUERY_RESPONSE_TIME_READ_WRITE statements.
It is not possible to specify flushing read and/or write statements with the FLUSH QUERY_RESPONSE_TIME_READ, FLUSH QUERY_RESPONSE_TIME_WRITE and FLUSH QUERY_RESPONSE_TIME_READ_WRITE statements.
Description: Updating this variable flushes the statistics and re-reads query_response_time_range_base.
Command line: None
Scope: Global
Dynamic: Yes
Data Type: boolean
Default Value: OFF
Description: Select base of log for QUERY_RESPONSE_TIME ranges. WARNING: variable change takes affect only after flush.
Command line: --query-response-time-range-base=#
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 10
Range: 2 to 1000
Description: Pretend queries take this many microseconds. When 0 (the default) use the actual execution time.
This system variable is only available when the plugin is a .
Scope: Global
Dynamic: Yes
Data Type: numeric
Default Value: 0
Range: 0 to 31536000
Description: Controls query response time statistics collection for the current session: ON - enable, OFF - disable, GLOBAL (default) - use query_response_time_stats value.
Command line: query-response-time-session-stats=val]
Scope: Global, Session
Dynamic: Yes
Data Type: enum
Default Value: GLOBAL
Valid Values: GLOBAL, ON, OFF
Introduced:
Description: Enable or disable query response time statistics collecting.
Command line: query-response-time-stats[={0|1}]
Scope: Global
Dynamic: Yes
Data Type: boolean
Default Value: OFF
Description: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --query-response-time=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
Description: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --query-response-time-audit=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
This page is licensed: CC BY-SA / Gnu FDL
Browse the complete reference of system variables for the Audit Plugin. Use these settings to fine-tune logging behavior, control performance impact, and manage log file handling.
There are a several options and system variables related to the MariaDB Audit Plugin, once it has been installed. System variables can be displayed using the SHOW VARIABLES statement like so:
To change the value of one of these variables, you can use the SET statement, or set them at the command-line when starting MariaDB. It's recommended that you set them in the MariaDB configuration for the server like so:
Below is a list of all system variables related to the Audit Plugin. See for a complete list of system variables and instructions on setting them. See also the .
server_audit_eventsDescription: If set, this restricts audit logging to certain event types. If not set, every event type is logged to the audit log.
Command line: --server-audit-events=value
Scope: Global
Dynamic: Yes
server_audit_excl_usersDescription: If not empty, it contains the list of users whose activity will NOT be logged: SET GLOBAL server_audit_excl_users='user_foo, user_bar'. CONNECT records aren't affected by this variable - they are always logged. The user is still logged if it's specified in .
Command line: --server-audit-excl-users=value
Scope: Global
server_audit_file_buffer_sizeDescription: Size (in bytes) of file buffer to make logging faster. Values > 0 are adjusted in increments of 8192. (For instance, a value of 100 would be adjusted to 8192.)
Command line: --server-audit-file-buffer-size=#
server_audit_file_pathDescription: When , sets the path and the filename to the log file. If the specified path exists as a directory, then the log will be created inside that directory with the name 'server_audit.log'. Otherwise the value is treated as a filename. The default value is 'server_audit.log', which means this file will be created in the database directory.
Command line: --server-audit-file-path=value
Scope: Global
server_audit_file_rotate_nowDescription: When , the user can force the log file rotation by setting this variable to ON or 1.
Command line: --server-audit-rotate-now[={0|1}]
Scope: Global
Dynamic: Yes
server_audit_file_rotate_sizeDescription: When , it limits the size of the log file to the given amount of bytes. Reaching that limit turns on the rotation - the current log file is renamed as 'file_path.1'. The empty log file is created as 'file_path' to log into it. The default value is 1000000.
Command line: --server-audit-rotate-size=#
Scope: Global
Dynamic: Yes
server_audit_file_rotationsDescription: When ', this specifies the number of rotations to save. If set to 0 then the log never rotates. The default value is 9.
Command line: --server-audit-rotations=#
Scope: Global
Dynamic: Yes
server_audit_incl_usersDescription: If not empty, it contains a comma-delimited list of users whose activity will be logged: SET GLOBAL server_audit_incl_users='user_foo, user_bar'. CONNECT records aren't affected by this variable - they are always logged. This setting has higher priority than . So if the same user is specified both in incl_ and excl_ lists, they will still be logged.
Command line: --server-audit-incl-users=value
Scope: Global
server_audit_loc_infoDescription: Used by plugin internals. It has no useful meaning to users.
In earlier versions, users see it as a read-only variable.
In later versions, it is hidden from the user.
Command line: N/A
server_audit_loggingDescription: Enables/disables the logging. Expected values are ON/OFF: SET GLOBAL server_audit_logging=on If the server_audit_output_type is FILE, this will actually create/open the logfile so the should be properly specified beforehand. Same about the SYSLOG-related parameters. The logging is turned off by default.
Command line: --server-audit-logging[={0|1}]
Scope: Global
server_audit_modeDescription: This variable doesn't have any distinctive meaning for a user. Its value mostly reflects the server version with which the plugin was started and is intended to be used by developers for testing.
Command line: --server-audit-mode[=#]
Scope: Global
Dynamic: Yes
server_audit_output_typeDescription: Specifies the desired output type. Can be SYSLOG, FILE or null as no output: SET GLOBAL server_audit_output_type=file file: log records will be saved into the rotating log file. The name of the file set by variable. syslog: log records will be sent to the local syslogd daemon with the standard <syslog.h> API. The default value is 'file'.
Command line: --server-audit-output-type=value
Scope: Global
server_audit_query_log_limitDescription: Limit on the length of the query string in a record.
Command line: --server-audit-query-log-limit=#
Scope: Global
Dynamic: Yes
server_audit_sync_log_fileDescription: Flushes the buffer to the log file.
While log records are in the buffer, they don't appear in the log file. To write them out from the buffer, issue this statement:
SET GLOBAL server_audit_log_file=1
Command line: --server-audit-sync-log-file
Scope: Global
server_audit_syslog_facilityDescription: SYSLOG-mode variable. It defines the 'facility' of the records that will be sent to the syslog. Later the log can be filtered by this parameter.
Command line: --server-audit-syslog-facility=value
Scope: Global
Dynamic: Yes
server_audit_syslog_identDescription: SYSLOG-mode variable. String value for the 'ident' part of each syslog record. Default value is 'mysql-server_auditing'. New value becomes effective only after restarting the logging.
Command line: --server-audit-syslog-ident=value
Scope: Global
Dynamic: Yes
server_audit_syslog_infoDescription: SYSLOG-mode variable. The 'info' string to be added to the syslog records. Can be changed any time.
Command line: --server-audit-syslog-info=value
Scope: Global
Dynamic: Yes
server_audit_syslog_priorityDescription: SYSLOG-mode variable. Defines the priority of the log records for the syslogd.
Command line: --server-audit-syslog-priority=value
Scope: Global
Dynamic: Yes
The server audit plugin typically employs synchronous, per-event logging, causing performance bottlenecks. Individual file writes for each log entry can result in significant I/O overhead, especially in large database environments. As of MariaDB 12.1, two new variables were introduced to allow asynchronous logging, and more fine grained control over how audit log writes are handled. Using the server_audit_file_buffer_size setting (buffer size in bytes), you can configure an additional in-memory audit log buffer. When the size of the buffer exceeds the server_audit_file_buffer_size setting, the audit log is written to disk. Additionally, a manual on-demand audit log disk sync can be triggered by setting server_audit_sync_log_file to ON or 1.
server_auditDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
INSTALL SONAME 'query_response_time';[mariadb]
...
plugin_load_add = query_response_timeSET GLOBAL query_response_time_stats=ON;[mariadb]
...
plugin_load_add = query_response_time
query_response_time_stats=ON;UNINSTALL SONAME 'query_response_time';(range_base ^ n; range_base ^ (n+1)](0; 10 ^ -6], (10 ^ -6; 10 ^ -5], (10 ^ -5; 10 ^ -4], ...,
(10 ^ -1; 10 ^1], (10^1; 10^2]...(10^7; positive infinity](0; 0.000001], (0.000001; 0.000010], (0.000010; 0.000100], ...,
(0.100000; 1.0]; (1.0; 10.0]...(1000000; positive infinity](0; 2 ^ -19], (2 ^ -19; 2 ^ -18], (2 ^ -18; 2 ^ -17], ...,
(2 ^ -1; 2 ^1], (2 ^ 1; 2 ^ 2]...(2 ^ 25; positive infinity](0; 0.000001], (0.000001, 0.000003], ...,
(0.25; 0.5], (0.5; 2], (2; 4]...(8388608; positive infinity]SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
+----------------+-------+----------------+
| TIME | COUNT | TOTAL |
+----------------+-------+----------------+
| 0.000001 | 0 | 0.000000 |
| 0.000010 | 17 | 0.000094 |
| 0.000100 | 4301 0.236555 |
| 0.001000 | 1499 | 0.824450 |
| 0.010000 | 14851 | 81.680502 |
| 0.100000 | 8066 | 443.635693 |
| 1.000000 | 0 | 0.000000 |
| 10.000000 | 0 | 0.000000 |
| 100.000000 | 1 | 55.937094 |
| 1000.000000 | 0 | 0.000000 |
| 10000.000000 | 0 | 0.000000 |
| 100000.000000 | 0 | 0.000000 |
| 1000000.000000 | 0 | 0.000000 |
| TOO LONG | 0 | TOO LONG |
+----------------+-------+----------------+* 17 queries with 0.000001 < query execution time < = 0.000010 seconds; total execution time of the 17 queries = 0.000094 seconds
* 4301 queries with 0.000010 < query execution time < = 0.000100 seconds; total execution time of the 4301 queries = 0.236555 seconds
* 1499 queries with 0.000100 < query execution time < = 0.001000 seconds; total execution time of the 1499 queries = 0.824450 seconds
* 14851 queries with 0.001000 < query execution time < = 0.010000 seconds; total execution time of the 14851 queries = 81.680502 seconds
* 8066 queries with 0.010000 < query execution time < = 0.100000 seconds; total execution time of the 8066 queries = 443.635693 seconds
* 1 query with 10.000000 < query execution time < = 100.0000 seconds; total execution time of the 1 query = 55.937094 secondsSELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;SELECT c.count, c.time,
(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME AS a
WHERE a.count != 0) AS query_count,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME AS b
WHERE b.count != 0) AS not_zero_region_count,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) AS region_count
FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME AS c
WHERE c.count > 0;SHOW QUERY_RESPONSE_TIME;FLUSH QUERY_RESPONSE_TIME;SET GLOBAL query_response_time_flush=1;SHOW GLOBAL VARIABLES LIKE 'server_audit%';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| server_audit_events | |
| server_audit_excl_users | |
| server_audit_file_buffer_size | 0 |
| ... | ... |
| server_audit_syslog_priority | LOG_INFO |
+-------------------------------+-----------------------+[mariadb]
...
server_audit_excl_users='bob,ted'
...Data type: string
Default value: Empty string
Valid values:
CONNECT, QUERY, TABLE (MariaDB Audit Plugin < 1.2.0)
CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML (MariaDB Audit Plugin >= 1.2.0)
CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML, QUERY_DCL (MariaDB Audit Plugin >=1.3.0)
CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML, QUERY_DCL, QUERY_DML_NO_SELECT (MariaDB Audit Plugin >= 1.4.4)
Consult for a list of MariaDB releases and their corresponding Audit Plugin versions.
Dynamic: Yes
Data type: string
Default value: Empty string
Size limit: 1024 characters
Scope: Global
Dynamic: Yes
Data type: numeric
Value range: 0 to 65536
Default value: 0 (no buffering)
Introduced: MariaDB 12.1
Usage: See description
Data type: string
Default value: server_audit.log
Data type: boolean
Default value: OFF
Data Type: numeric
Default Value: 1000000
Range: 100 to 9223372036854775807
Data type: numeric
Default value: 9
Range: 0 to 999
Dynamic: Yes
Data type: string
Default value: Empty string
Size limit: 1024 characters
Scope: Global
Dynamic: No
Data Type: string
Default Value: Empty string
Dynamic: Yes
Data type: boolean
Default value: OFF
Data type: numeric
Default value: 0
Range: 0 to 1
Dynamic: Yes
Data type: enum
Default value: file
Valid values: SYSLOG, FILE
Data type: numeric
Default value: 1024
Range: 0 to 2147483647
Data type: N/A
Default value: OFF
Valid values: ON (or 1), OFF (or 0)
Introduced: MariaDB 12.1
Usage: See description
Data type: enum
Default value: LOG_USER
Valid values: LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, LOG_SYSLOG, LOG_LPR, LOG_NEWS, LOG_UUCP, LOG_CRON, LOG_AUTHPRIV, LOG_FTP, and LOG_LOCAL0–LOG_LOCAL7.
Data type: string
Default value: mysql-server_auditing
Data type: string
Default value: Empty string
Data type: enum
Default value: LOG_INFO
Valid values:LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See MariaDB Audit Plugin - Installation: Prohibiting Uninstallation for more information.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --server-audit=val
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
The gssapi authentication plugin enables passwordless single sign-on by authenticating users via the Generic Security Services API, supporting Kerberos on Unix and Windows.
The gssapi authentication plugin allows the user to authenticate with services that use the Generic Security Services Application Program Interface (GSSAPI). Windows has a slightly different but very similar API called Security Support Provider Interface (SSPI). The GSSAPI is a standardized API described in RFC2743 and RFC2744. The client and server negotiate using a standardized protocol described in RFC7546.
On Windows, this authentication plugin supports Kerberos and NTLM authentication. Windows authentication is supported regardless of whether a domain is used in the environment.
On Unix systems, the most dominant GSSAPI service is Kerberos. However, it is less commonly used on Unix systems than it is on Windows. Regardless, this authentication plugin also supports Kerberos authentication on Unix.
The gssapi authentication plugin is most often used for authenticating with Microsoft Active Directory.
This article gives instructions on configuring the gssapi authentication plugin
for MariaDB for passwordless login.
The gssapi authentication plugin's shared library is included in MariaDB packages as the auth_gssapi.so or auth_gssapi.dll shared library on systems where it can be built.
The gssapi authentication plugin is included in on Linux.
The gssapi authentication plugin can also be installed via a package manager on Linux. In order to do so, your system needs to be configured to install from one of the MariaDB repositories.
You can configure your package manager to install it from MariaDB Corporation's MariaDB Package Repository by using the .
You can also configure your package manager to install it from MariaDB Foundation's MariaDB Repository by using the .
Installing with yum/dnf
On RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using or . Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf:
Installing with apt-get
On Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using :
Installing with zypper
On SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant from MariaDB's repository using :
On Windows, and on other operating systems, although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing or :
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options must be removed to prevent the plugin from being loaded the next time the server is restarted.
If the MariaDB server is running on Unix, then some additional configuration steps will need to be implemented in order to use the plugin.
If the MariaDB server is running on Windows, then no special configuration steps will need to be implemented in order to use the plugin, as long as the following is true:
The Windows server is joined to a domain.
The MariaDB server process is running as either a or a .
If the MariaDB server is running on Unix, then the KDC server will need to create a keytab file for the MariaDB server. The keytab file contains the service principal name, which is the identity that the MariaDB server will use to communicate with the KDC server. The keytab will need to be transferred to the MariaDB server, and the mysqld server process will need read access to this keytab file.
How this keytab file is generated depends on whether the KDC server is or .
If you are using , you may need to create a keytab using the utility on a Windows host. The service principal will need to be mapped to an existing domain user. To do so, follow the steps listed below.
Be sure to replace the following items in the step below:
Replace ${HOST} with the fully qualified DNS name for the MariaDB server host.
Replace ${DOMAIN} with the Active Directory domain.
Replace ${AD_USER} with the existing domain user.
To create the service principal, execute the following command:
If you are using , then you can create a file using the utility. To do so, follow the steps listed below.
In the following steps, be sure to replace ${HOST} with the fully qualified DNS name for the MariaDB server host.
First, create the service principal using the utility:
Then, export the newly created user to the keytab file using the utility:
More details can be found at the following links:
If the MariaDB server is running on Unix, then the path to the keytab file that was previously created can be set by configuring the system variable. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server in an :
The service principal name can be set by configuring the system variable. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server in an :
If a service principal name is not provided, the plugin tries to use mariadb/host.domain.com@REALM by default.
If the MariaDB server is running on Unix, the plugin needs a service principal name in order to function.
If the MariaDB server is running on Windows, the plugin does not usually need a service principal in order to function. However, if you want to use one, anyway, it can be created with the setspn utility.
Different KDC implementations may use different canonical forms to identify principals. See to learn what the standard says about principal names.
More details can be found at the following links:
To create a user account via , specify the name of the plugin in the clause:
If does not have NO_AUTO_CREATE_USER set, then you can also create the user account via :
You can also specify the user's for MariaDB with the USING clause:
The format of the realm depends on the specific authentication mechanism that is used. For example, the format would need to be machine\\username for Windows users authenticating with NTLM.
If the realm is not provided in the user account's definition, then the realm is not used for comparison. Therefore, 'usr1@EXAMPLE.COM', 'usr1@EXAMPLE.CO.UK' and 'mymachine\usr1' would all identify as the following user account:
On Windows only, it is possible to login using a AD or local group-membership. This is achieved by using the GROUP prefix in IDENTIFIED ... AS:
The effect of the above definition is that every user that identifies as a member of group Administrators can log in using the user name root without a password.
User can also login using own or group (Security Identifier):
Using SIDs will perform slightly faster than using name (since it will spare translation between SID and name which is otherwise done). SIDs are immune against user or group renaming.
On Windows, in addition to the usual authentication with a password, passwordless authentication is permitted when creating the root user during installation. This works in a similar manner to . However, since auth_gssapi, unlike unix_socket, requires client support, to avoid failures when MariaDB is used with third-party drivers, authentication on Windows first attempts password-based native_authentication, and only if it fails, falls back to passwordless auth_gssapi.
For clients that use the libmysqlclient or libraries, MariaDB provides one client authentication plugin that is compatible with the gssapi authentication plugin:
auth_gssapi_client
When connecting with a to a server as a user account that authenticates with the gssapi authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:
auth_gssapi_clientThe auth_gssapi_client client authentication plugin receives the principal name from the server, and then uses either the function (on Unix) or the function (on Windows) to establish a security context on the client.
supports gssapi authentication using the mentioned in the previous section.
supports gssapi authentication using the mentioned in the previous section.
supports gssapi authentication. Current documentation can be found .
does not yet support gssapi authentication. See for more information.
supports gssapi authentication.
The support is transparent. Normally, the connector only needs to be provided the correct user name, and no other parameters are required.
However, this connector also supports the connection string parameter, which can be used for mutual authentication.
When connecting from Unix client to Windows server with ADO.NET, in an Active Directory domain environment, be aware that .NET Core on Unix does not support principal names in UPN(User Principal Name) form, which is default on Windows (e.g machine$@domain.com) . Thus, upon encountering an authentication exception with "server not found in Kerberos database", use one of workarounds below
Force host-based SPN on server side.
For example, this can be done by setting the system variable to HOST/machine in a server in an .
Pass host-based SPN on client side.
gssapi_keytab_pathDescription: Defines the path to the server's keytab file.
This system variable is only meaningful on Unix.
See and for more information.
Command line: --gssapi-keytab-path
gssapi_principal_nameDescription: Name of the service principal.
See for more information.
Command line: --gssapi-principal-name
Scope: Global
gssapi_mech_nameDescription: Name of the SSPI package used by server. Can be either 'Kerberos' or 'Negotiate'. Set it to 'Kerberos', to prevent less secure NTLM in domain environments, but leave it as default (Negotiate) to allow non-domain environments (e.g if server does not run in a domain environment).
This system variable is only meaningful on Windows.
Command line: --gssapi-mech-name
gssapiDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
${PASSWORD} with the password for the service principal.HOST/machine.Scope: Global
Dynamic: No
Data Type: string
Default Value: ''
Introduced: MariaDB 10.1.11
Dynamic: No
Data Type: string
Default Value: ''
Introduced: MariaDB 10.1.11
Dynamic: No
Data Type: enumerated
Default Value: Negotiate
Valid Values: Kerberos, Negotiate
Introduced: MariaDB 10.1.11
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --gssapi=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
Introduced: MariaDB 10.1.11
Learn to configure the PAM plugin to authenticate users via LDAP and map LDAP groups to MariaDB accounts using the pam_user_map module.
In this article, we will walk through the configuration of PAM authentication using the authentication plugin and user and group mapping with the PAM module. The primary authentication will be handled by the PAM module, which performs LDAP authentication. We will also set up an OpenLDAP server.
In this walkthrough, we are going to assume the following hypothetical requirements:
sudo yum install MariaDB-gssapi-serversudo apt-get install mariadb-plugin-gssapi-serversudo zypper install MariaDB-gssapi-serverINSTALL SONAME 'auth_gssapi';[mariadb]
...
plugin_load_add = auth_gssapiUNINSTALL SONAME 'auth_gssapi';ktpass.exe /princ mariadb/${HOST}@${DOMAIN} /mapuser ${AD_USER} /pass ${PASSWORD} /out mariadb.keytab /crypto all /ptype KRB5_NT_PRINCIPAL /mapop setkadmin -q "addprinc -randkey mariadb/${HOST}"kadmin -q "ktadd -k /path/to/mariadb.keytab mariadb/${HOST}"[mariadb]
...
gssapi_keytab_path=/path/to/mariadb.keytab[mariadb]
...
gssapi_principal_name=service_principal_name/host.domain.com@REALMCREATE USER username@hostname IDENTIFIED VIA gssapi;GRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA gssapi;CREATE USER username@hostname IDENTIFIED VIA gssapi USING 'username@EXAMPLE.COM';CREATE USER usr1@hostname IDENTIFIED VIA gssapi;CREATE USER root IDENTIFIED VIA gssapi AS 'GROUP:Administrators'
CREATE USER root IDENTIFIED VIA gssapi AS 'GROUP:BUILTIN\\Administrators'CREATE USER root IDENTIFIED VIA gssapi AS 'SID:S-1-5-32-544'mysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alicefoo should be mapped to the MariaDB user bar. (foo: bar)Any LDAP user in the LDAP group dba should be mapped to the MariaDB user dba. (@dba: dba)
Before we can use LDAP authentication, we first need to set up our OpenLDAP Server. This is usually done on a server that is completely separate from the database server.
On the server acting as the OpenLDAP Server, first, we need to install the OpenLDAP components.
On RHEL, CentOS, and other similar Linux distributions that use RPM packages, that would go like this:
Next, let's to configure the OpenLDAP Server. The easiest way to do that is to copy the template configuration file that is included with the installation. In many installations, that will be at /usr/share/openldap-servers/DB_CONFIG.example:
Sometimes it is useful to change the port used by OpenLDAP. For example, some cloud environments block well-known authentication services, so they block the default LDAP port.
On some systems, the port can be changed by setting SLAPD_URLS in /etc/sysconfig/slapd:
I used 3306 because that is the port that is usually used by mysqld, so I know that it is not blocked.
Next, let's start the OpenLDAP Server and configure it to start on reboot. On systemd systems, that would go like this:
In order to use LDAP for authentication, we also need to install some standard objectClasses, such as posixAccount and posixGroup. In LDAP, things like objectClasses are defined in LDIF files. In many installations, these specific objectClasses are defined in /etc/openldap/schema/nis.ldif. nis.ldif also depends on core.ldif and cosine.ldif. However, core.ldif is usually installed by default.
We can install them with ldapmodify:
Next, let’s create a directory manager user. We can do this by using OpenLDAP's olc configuration system to change the olcRootDN directive to the DN of the directory manager user, which means that the user will be a privileged LDAP user that is not subject to access controls. We will also set the root password for the user by changing the olcRootPW directive.
We will also set the DN suffix for our backend LDAP database by changing the olcSuffix directive.
Let’s use the slappasswd utility to generate a password hash from a clear-text password. Simply execute:
This utility provides a password hash that looks like this: {SSHA}AwT4jrvmokeCkbDrFAnGvzzjCMb7bvEl
OpenLDAP's olc configuration system also uses LDIF files. Now that we have the password hash, let’s create an LDIF file to create the directory manager user:
Note that this is using the dc=support,dc=mariadb,dc=com domain for the directory. You can change it to whatever is relevant to you.
Now let’s run the ldif file with ldapmodify:
We will use the new directory manager user to make changes to the LDAP directory after this step.
Next, let's create the structure of the directory by creating parts of our tree.
Now, let’s use our new directory manager user and run the LDIF file with ldapmodify:
Let's go ahead and create the LDAP users and groups that we are using for this scenario.
First, let's create the foo user:
Next, let's create a couple of users to go into the dba group:
Note that each of these users needs a password, so we can set it for each user with ldappasswd:
Next, let's create our dba group:
Next, let's add our two users to it:
We also need to create LDAP users with the same name as the bar and dba MariaDB users. See here to read more about the reasons to do so. No one will be logging in as these users, so they do not need passwords. Instead of the People organizationalUnit, we create them in the System Users organizationalUnit.
At this point, we can move on to setting up the MariaDB Server.
First, we need to make sure that the LDAP and PAM libraries are installed.
On RHEL, CentOS, and other similar Linux distributions that use RPM packages, we need to install the following packages:
Next, let's configure LDAP on the system. We can use authconfig for this:
Be sure to replace -–ldapserver and -–ldapbasedn with values that are relevant for your environment.
The pam_user_map PAM module is included in the base install. No installation is needed.
Next, let's install the pam_user_map PAM module.
Before the module can be compiled from source, we may need to install some dependencies.
On RHEL, CentOS, and other similar Linux distributions that use RPM packages, we need to install gcc and pam-devel:
On Debian, Ubuntu, and other similar Linux distributions that use DEB packages, we need to install gcc and libpam0g-dev:
And then we can build and install the library with the following:
Next, let's configure the pam_user_map PAM module based on our hypothetical requirements.
The configuration file for the pam_user_map PAM module is /etc/security/user_map.conf. Based on our requirements, ours would look like:
Next, let's install the pam authentication plugin.
Log into the MariaDB Server and execute the following:
Next, let's configure the PAM service. We will call our service mariadb, so our PAM service configuration file will be located at /etc/pam.d/mariadb on most systems.
Since we are only doing LDAP authentication with the pam_ldap PAM module and group mapping with the pam_user_map PAM module, our configuration file would look like this:
If we want to allow authentication from LDAP users and from local Unix users through pam_unix, while giving priority to the local users, then we could do this instead:
Configuring the pam_unix PAM Module
If you also want to allow authentication from local Unix users, the pam_unix PAM module adds some additional configuration steps on a lot of systems. We basically have to give the user that runs mysqld access to /etc/shadow.
If the mysql user is running mysqld, then we can do that by executing the following:
The server needs to be restarted for this change to take affect.
Next, let's create the MariaDB users. Remember that our PAM service is called mariadb.
First, let's create the MariaDB user for the user mapping: foo: bar
That means that we need to create a bar user:
And then let's create the MariaDB user for the group mapping: @dba: dba
That means that we need to create a dba user:
And then to allow for the user and group mapping, we need to create an anonymous user that authenticates with the pam authentication plugin that is also able to PROXY as the bar and dba users. Before we can create the proxy user, we might need to clean up some defaults:
And then let's create the anonymous proxy user:
Next, let's test our configuration by verifying that mapping is occurring. We can verify this by logging in as each of our users and comparing the return value of USER(), which is the original user name and the return value of CURRENT_USER(), which is the authenticated user name.
First, let's test our foo user:
We can verify that our foo LDAP user was properly mapped to the bar MariaDB user by looking at the return value of CURRENT_USER().
Then let's test our gmontee user in the dba group:
And then let's test our bstillman user in the dba group:
We can verify that our gmontee and bstillman LDAP users in the dba LDAP group were properly mapped to the dba MariaDB user by looking at the return values of CURRENT_USER().
If you chose the option that also allowed local Unix authentication, then let's test that out. Let's create a Unix user and give the user a password real quick:
And let's also map this user to dba:
And we know that the existing anonymous user already has the PROXY privilege granted to the dba user, so this should just work without any other configuration. Let's test it out:
We can verify that our alice Unix user was properly mapped to the dba MariaDB user by looking at the return values of CURRENT_USER().
If you are connecting to MariaDB Server through MariaDB MaxScale, it is also recommended to configure the proxy to authenticate users via .
This page is licensed: CC BY-SA / Gnu FDL
This plugin creates the METADATA_LOCK_INFO table in the Information Schema, allowing users to view active metadata locks and their owners.
The METADATA_LOCK_INFO plugin creates the METADATA_LOCK_INFO table in the INFORMATION_SCHEMA database. This table shows active metadata locks. The table is empty if there are no active metadata locks.
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the or the options. This can be specified as a command-line argument to or it can be specified in a relevant server in an :
You can uninstall the plugin dynamically by executing or :
If you installed the plugin by providing the or the options in a relevant server in an , then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.
metadata_lock_infoDescription: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the table.
This page is licensed: CC BY-SA / Gnu FDL
sudo yum install gcc pam-develsudo apt-get install gcc libpam0g-devsudo yum install openldap openldap-servers openldap-clients nss-pam-ldapdsudo cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
sudo chown ldap. /var/lib/ldap/DB_CONFIGSLAPD_URLS="ldapi:/// ldap://0.0.0.0:3306/"sudo systemctl start slapd
sudo systemctl enable slapdsudo ldapmodify -a -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
sudo ldapmodify -a -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldifslappasswdtee ~/setupDirectoryManager.ldif <<EOF
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to *
by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
by dn.base="cn=Manager,dc=support,dc=mariadb,dc=com" read
by * none
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=support,dc=mariadb,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=support,dc=mariadb,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}AwT4jrvmokeCkbDrFAnGvzzjCMb7bvEl
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange
by dn="cn=Manager,dc=support,dc=mariadb,dc=com" write
by anonymous auth
by self write
by * none
olcAccess: {1}to dn.base=""
by * read
olcAccess: {2}to *
by dn="cn=Manager,dc=support,dc=mariadb,dc=com" write
by * read
EOFsudo ldapmodify -Y EXTERNAL -H ldapi:/// -f ~/setupDirectoryManager.ldiftee ~/setupDirectoryStructure.ldif <<EOF
dn: dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: dcObject
objectclass: organization
o: MariaDB Support Team
dc: support
dn: cn=Manager,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: organizationalRole
cn: Manager
description: Directory Manager
dn: ou=People,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: organizationalUnit
ou: People
dn: ou=Groups,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: organizationalUnit
ou: Groups
dn: ou=System Users,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: organizationalUnit
ou: System Users
EOFldapmodify -a -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -f ~/setupDirectoryStructure.ldiftee ~/createFooUser.ldif <<EOF
dn: uid=foo,ou=People,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: foo
uid: foo
uidNumber: 16859
gidNumber: 100
homeDirectory: /home/foo
loginShell: /bin/bash
gecos: foo
userPassword: {crypt}x
shadowLastChange: -1
shadowMax: -1
shadowWarning: 0
EOF
ldapmodify -a -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -f ~/createFooUser.ldiftee ~/createDbaUsers.ldif <<EOF
dn: uid=gmontee,ou=People,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: gmontee
uid: gmontee
uidNumber: 16860
gidNumber: 100
homeDirectory: /home/gmontee
loginShell: /bin/bash
gecos: gmontee
userPassword: {crypt}x
shadowLastChange: -1
shadowMax: -1
shadowWarning: 0
dn: uid=bstillman,ou=People,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: bstillman
uid: bstillman
uidNumber: 16861
gidNumber: 100
homeDirectory: /home/bstillman
loginShell: /bin/bash
gecos: bstillman
userPassword: {crypt}x
shadowLastChange: -1
shadowMax: -1
shadowWarning: 0
EOF
ldapmodify -a -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -f ~/createDbaUsers.ldifldappasswd -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -S uid=foo,ou=People,dc=support,dc=mariadb,dc=com
ldappasswd -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -S uid=gmontee,ou=People,dc=support,dc=mariadb,dc=com
ldappasswd -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -S uid=bstillman,ou=People,dc=support,dc=mariadb,dc=comtee ~/createDbaGroup.ldif <<EOF
dn: cn=dba,ou=Groups,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: posixGroup
gidNumber: 678
EOF
ldapmodify -a -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -f ~/createDbaGroup.ldiftee ~/addUsersToDbaGroup.ldif <<EOF
dn: cn=dba,ou=Groups,dc=support,dc=mariadb,dc=com
changetype: modify
add: memberuid
memberuid: gmontee
dn: cn=dba,ou=Groups,dc=support,dc=mariadb,dc=com
changetype: modify
add: memberuid
memberuid: bstillman
EOF
ldapmodify -a -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -f ~/addUsersToDbaGroup.ldiftee ~/createSystemUsers.ldif <<EOF
dn: uid=bar,ou=System Users,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: bar
uid: bar
uidNumber: 16862
gidNumber: 100
homeDirectory: /home/bar
loginShell: /bin/bash
gecos: bar
userPassword: {crypt}x
shadowLastChange: -1
shadowMax: -1
shadowWarning: 0
dn: uid=dba,ou=System Users,dc=support,dc=mariadb,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: dba
uid: dba
uidNumber: 16863
gidNumber: 100
homeDirectory: /home/dba
loginShell: /bin/bash
gecos: dba
userPassword: {crypt}x
shadowLastChange: -1
shadowMax: -1
shadowWarning: 0
EOF
ldapmodify -a -x -D cn=Manager,dc=support,dc=mariadb,dc=com -W -f ~/createSystemUsers.ldifsudo yum install openldap-clients nss-pam-ldapd pam pam-develsudo authconfig --enableldap \
--enableldapauth \
--ldapserver="ldap://172.30.0.238:3306" \
--ldapbasedn="dc=support,dc=mariadb,dc=com" \
--enablemkhomedir \
--updatefoo: bar
@dba:dbaINSTALL SONAME 'auth_pam';auth required pam_ldap.so
auth required pam_user_map.so
account required pam_ldap.soauth [success=1 new_authtok_reqd=1 default=ignore] pam_unix.so audit
auth required pam_ldap.so try_first_pass
auth required pam_user_map.so
account sufficient pam_unix.so audit
account required pam_ldap.sosudo groupadd shadow
sudo usermod -a -G shadow mysql
sudo chown root:shadow /etc/shadow
sudo chmod g+r /etc/shadowCREATE USER 'bar'@'%' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON *.* TO 'bar'@'%' ;CREATE USER 'dba'@'%' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'%' ;DELETE FROM mysql.db WHERE User='' AND Host='%';
FLUSH PRIVILEGES;CREATE USER ''@'%' IDENTIFIED VIA pam USING 'mariadb';
GRANT PROXY ON 'bar'@'%' TO ''@'%';
GRANT PROXY ON 'dba'@'%' TO ''@'%';$ mysql -u foo -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 134
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+------------------------------------------------+----------------+
| foo@ip-172-30-0-198.us-west-2.compute.internal | bar@% |
+------------------------------------------------+----------------+
1 row in set (0.000 sec)$ mysql -u gmontee -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 135
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+----------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+----------------------------------------------------+----------------+
| gmontee@ip-172-30-0-198.us-west-2.compute.internal | dba@% |
+----------------------------------------------------+----------------+
1 row in set (0.000 sec)$ mysql -u bstillman -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 136
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+------------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+------------------------------------------------------+----------------+
| bstillman@ip-172-30-0-198.us-west-2.compute.internal | dba@% |
+------------------------------------------------------+----------------+
1 row in set (0.000 sec)sudo useradd alice
sudo passwd alice@dba:dba
foo: bar
alice: dba$ mysql -u alice -h 172.30.0.198
[mariadb] Password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 141
Server version: 10.3.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT USER(), CURRENT_USER();
+--------------------------------------------------+----------------+
| USER() | CURRENT_USER() |
+--------------------------------------------------+----------------+
| alice@ip-172-30-0-198.us-west-2.compute.internal | dba@% |
+--------------------------------------------------+----------------+
1 row in set (0.000 sec)INSTALL SONAME 'metadata_lock_info';ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.
See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.
Command line: --metadata-lock-info=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
[mariadb]
...
plugin_load_add = metadata_lock_infoUNINSTALL SONAME 'metadata_lock_info';SELECT * FROM information_schema.metadata_lock_info;
+-----------+--------------------------+---------------+----------------------+-----------------+-------------+
| THREAD_ID | LOCK_MODE | LOCK_DURATION | LOCK_TYPE | TABLE_SCHEMA | TABLE_NAME |
+-----------+--------------------------+---------------+----------------------+-----------------+-------------+
| 31 | MDL_INTENTION_EXCLUSIVE | MDL_EXPLICIT | Global read lock | | |
| 31 | MDL_INTENTION_EXCLUSIVE | MDL_EXPLICIT | Commit lock | | |
| 31 | MDL_INTENTION_EXCLUSIVE | MDL_EXPLICIT | Schema metadata lock | dbname | |
| 31 | MDL_SHARED_NO_READ_WRITE | MDL_EXPLICIT | Table metadata lock | dbname | exotics |
+-----------+--------------------------+---------------+----------------------+-----------------+-------------+
4 rows in set (0.00 sec)SELECT
CONCAT('Thread ',P.ID,' executing "',P.INFO,'" IS LOCKED BY Thread ',
M.THREAD_ID) WhoLocksWho
FROM INFORMATION_SCHEMA.PROCESSLIST P,
INFORMATION_SCHEMA.METADATA_LOCK_INFO M
WHERE LOCATE(lcase(LOCK_TYPE), lcase(STATE))>0;
+-----------------------------------------------------------------------------------+
| WhoLocksWho |
+-----------------------------------------------------------------------------------+
| Thread 3 executing "INSERT INTO foo ( b ) VALUES ( 'FOO' )" IS LOCKED BY Thread 2 |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
SHOW PROCESSLIST;
+----+------+-----------+------+---------+------+------------------------------+----------------------------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+----+------+-----------+------+---------+------+------------------------------+----------------------------------------+----------+
| 2 | root | localhost | test | Sleep | 123 | | NULL | 0.000 |
| 3 | root | localhost | test | Query | 103 | Waiting for global read lock | INSERT INTO foo ( b ) VALUES ( 'FOO' ) | 0.000 |
| 4 | root | localhost | test | Query | 0 | init | SHOW PROCESSLIST | 0.000 |
+----+------+-----------+------+---------+------+------------------------------+----------------------------------------+----------+
3 rows in set (0.00 sec)wget https://raw.githubusercontent.com/MariaDB/server/10.4/plugin/auth_pam/mapper/pam_user_map.c
gcc pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so
sudo install --mode=0755 pam_user_map.so /lib64/security/Pluggable authentication allows MariaDB to use various authentication methods, enabling external validation, different hashing algorithms, and role-based access control.
When a user attempts to log in, the authentication plugin controls how MariaDB Server determines whether the connection is from a legitimate user.
When creating or altering a user account with the GRANT, CREATE USER or ALTER USER statements, you can specify the authentication plugin you want the user account to use, by providing the IDENTIFIED VIA clause. By default, when you create a user account without specifying an authentication plugin, MariaDB uses the mysql_native_password plugin.
You can specify multiple authentication plugins for each user account.
The root@localhost user created by has the ability to use two authentication plugins:
It is configured to try to use the authentication plugin. This allows the root@localhost user to log in without a password via the local Unix socket file defined by the system variable, as long as the login is attempted from a process owned by the operating system root user account.
If authentication fails with the authentication plugin, it is configured to try to use the authentication plugin. However, an invalid password is initially set, so in order to authenticate this way, a password must be set with .
The authentication process is a conversation between the server and a client. MariaDB implements both server-side and client-side authentication plugins.
MariaDB provides seven server-side authentication plugins:
MariaDB provides eight client-side authentication plugins:
MariaDB supports the following server options related to authentication plugins:
Most support command-line arguments related to client authentication plugins:
Developers who are using can implement similar functionality in their application by setting the following options with the function:
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
MYSQL_PLUGIN_DIR
MYSQL_DEFAULT_AUTH
For example:
supports the following installation options related to authentication plugins:
MariaDB has extended the SQL standard , , and statements, so that they support specifying different authentication plugins for specific users. An authentication plugin can be specified with these statements by providing the IDENTIFIED VIA clause. Examples:
The optional USING clause allows users to provide an authentication string to a plugin. The authentication string's format and meaning is completely defined by the plugin.
For example, for the authentication plugin, the authentication string should be a password hash:
Since is the default authentication plugin, the above is just another way of saying the following:
In contrast, for the authentication plugin, the authentication string should refer to a :
A user account can be associated with multiple authentication plugins.
To configure the root@localhost user account to try the authentication plugin, followed by the authentication plugin as a backup, execute the following query:
See for more information.
Not all server-side authentication plugins are installed by default. If a specific server-side authentication plugin is not installed by default, then you can find the installation procedure on the documentation page for the specific authentication plugin.
The following server-side authentication plugins are installed by default:
The and authentication plugins authentication plugins are installed by default in all builds.
The authentication plugin is installed by default in all builds on Unix and Linux.
The authentication plugin is installed by default in all builds on Windows.
The following server-side authentication plugins are installed by default:
The and authentication plugins are installed by default in all builds.
The authentication plugin is installed by default in new installations that use the packages provided by Debian's default repositories and Ubuntu's default repositories in Ubuntu. See for more information.
The authentication plugin is installed by default in all builds on Windows.
Client-side authentication plugins do not need to be installed in the same way that server-side authentication plugins do. If the client uses either the libmysqlclient or library, then the library automatically loads client-side authentication plugins from the library's plugin directory whenever they are needed.
Most support the --plugin-dir command line argument that can be used to set the path to the library's plugin directory:
Developers who are using can implement similar functionality in their application by setting the MYSQL_PLUGIN_DIR option with the function. Example:
If your client encounters errors similar to the following error, you may need to set the path to the library's plugin directory:
If the client does not use either the libmysqlclient or library, then you will have to determine which authentication plugins are supported by the specific client library used by the client.
If the client uses either the libmysqlclient or library, but the client is not bundled with either library's optional client authentication plugins, then you can only use the conventional authentication plugins (like and ) and the non-conventional authentication plugins that don't require special client-side authentication plugins (like and ).
The authentication plugin is currently the default authentication plugin in all versions of MariaDB if the system variable is set to 0, which is the default.
On a system with the system variable set to 0, this means that if you create a user account with either the or statements, and if you do not specify an authentication plugin with theIDENTIFIED VIAclause, then MariaDB will use the [mysql_native_password](authentication-plugin-mysql_native_password.md) authentication plugin for the user account.
Creating a user account like this, it uses the authentication plugin:
The same is true for this user account:
The authentication plugin becomes the default authentication plugin in all versions of MariaDB, if the system variable is explicitly set to 1.
The authentication plugin is not considered secure. It is recommended to avoid using this authentication plugin. To help prevent undesired use of the authentication plugin, the server supports the system variable that configures the server to refuse connections trying to use the authentication plugin.
Most support secure_auth.
Developers using can implement similar functionality in their application by setting the MYSQL_SECURE_AUTH option with the function:
The default client-side authentication plugin depends on these factors:
If a client doesn't explicitly set the default client-side authentication plugin, the client determines which authentication plugin to use, by checking the length of the scramble in the server's handshake packet.
If the server's handshake packet contains a 9-byte scramble, the client defaults to the authentication plugin.
If the server's handshake packet contains a 20-byte scramble, the client defaults to the authentication plugin.
Most support the --default-auth command-line argument that sets the default client-side authentication plugin:
Developers using can implement similar functionality in applications, by setting the MYSQL_DEFAULT_AUTH option with the function:
If you know that your user account is configured to require a client-side authentication plugin other than or , this helps speed up your connection process when you explicitly set the default client-side authentication plugin.
According to the , the server first sends the handshake packet to the client, then the client replies with a packet containing the user name of the user account that is requesting access. The server handshake packet initially tells the client to use the default server authentication plugin, and the client reply initially tells the server that it will use the default client authentication plugin.
However, the server-side and client-side authentication plugins mentioned in these initial packets may not be the correct ones for this specific user account. The server only knows what authentication plugin to use for this specific user account after reading the user name from the client reply packet and finding the appropriate row for the user account in either the table or the table, depending on the MariaDB version.
If the server finds that either the server-side or client-side default authentication plugin does not match the actual authentication plugin that should be used for the given user account, then the server restarts the authentication on either the server side or the client side.
This means that, if you know what client authentication plugin your user account requires, then you can avoid an unnecessary authentication restart and you can save two packets and two round-trips.between the client and server by configuring your client to use the correct authentication plugin by default.
mysql_native_passwordThe authentication plugin uses the same password hashing algorithm used by the function when is set. This hashing algorithm is based on .
mysql_old_passwordThe authentication plugin uses the same hashing algorithm used by the function and by the function when is set.
ed25519The authentication plugin uses the to securely store users' passwords and to authenticate users. The algorithm is the same one that is . It is based on the elliptic curve and code created by .
gssapiThe authentication plugin allows authenticating with services that use the . Windows has a slightly different but very similar API called .
On Windows, this authentication plugin supports and authentication. Windows authentication is supported regardless of whether a is used in the environment.
On Unix systems, the most dominant GSSAPI service is . However, it is less commonly used on Unix systems than it is on Windows. Regardless, this authentication plugin also supports Kerberos authentication on Unix.
The authentication plugin is most often used for authenticating with .
pamThe authentication plugin allows MariaDB to offload user authentication to the system's framework. PAM is an authentication framework used by Linux, FreeBSD, Solaris, and other Unix-like operating systems.
unix_socketThe authentication plugin allows the user to use operating system credentials when connecting to MariaDB via the local Unix socket file. This Unix socket file is defined by the system variable.
The authentication plugin works by calling the system call with the SO_PEERCRED socket option, which allows it to retrieve the uid of the process that is connected to the socket. It is then able to get the user name associated with that uid. Once it has the user name, it will authenticate the connecting user as the MariaDB account that has the same user name.
For example:
In this example, a user serg is already logged into the operating system and has full shell access. The user has already authenticated with the operating system and the MariaDB account is configured to use the authentication plugin, so the user does not need to authenticate again for the database. MariaDB accepts the user's operating system credentials and allows connecting. However, any attempt to connect to the database as another operating system user will be denied.
named_pipeThe authentication plugin allows the user to use operating system credentials when connecting to MariaDB via named pipe on Windows. Named pipe connections are enabled by the system variable.
The authentication plugin works by using and calling GetUserName() to retrieve the user name of the process that is connected to the named pipe. Once it has the user name, it authenticates the connecting user as the MariaDB account that has the same user name:
The authentication plugin API is extensively documented in the in the following files:
mysql/plugin_auth.h (server part)
mysql/client_plugin.h (client part)
mysql/plugin_auth_common.h (common parts)
The MariaDB also contains some authentication plugins that are intended explicitly to be examples for developers. They are located in plugin/auth_examples.
The definitions of two example authentication plugins called two_questions and three_attempts can be seen in plugin/auth_examples/dialog_examples.c. These authentication plugins demonstrate how to communicate with the user using the client authentication plugin.
The two_questions authentication plugin asks the user for a password and a confirmation ("Are you sure?").
The three_attempts authentication plugin gives the user three attempts to enter a correct password.
The password for both of these plugins should be specified in the plain text in the USING clause:
The client authentication plugin, strictly speaking, is not part of the client-server or authentication plugin API. But it can be loaded into any client application that uses the libmysqlclient or libraries. This authentication plugin provides a way for the application to customize the UI of the dialog function.
In order to use the client authentication plugin to communicate with the user in a customized way, the application will need to implement a function with the following signature:
The function takes the following arguments:
The connection handle.
A question "type", which has one of the following values:
1 - Normal question
2
The function returns a pointer to a string of characters, as entered by the user. It may be stored in buf or allocated with malloc().
By using this function, a GUI application can open a dialog window, and a network application can send the question over the network, as required. If no mysql_authentication_dialog_ask function is provided by the application, the client authentication plugin falls back to and .
Providing this callback is particularly important on Windows, because Windows GUI applications have no associated console and the default dialog function will not be able to reach the user. An example of Windows GUI client that does it correctly is .
This page is licensed: CC BY-SA / Gnu FDL
unix_socket (Unix only)
named_pipe (Windows only)
MYSQL_SECURE_AUTHA prompt.
A buffer.
The length of the buffer.
If set to 1 (0 is default), MariaDB reverts to using the mysql_old_password authentication plugin by default for newly created users and passwords, instead of the mysql_native_password authentication plugin.
Path to the plugin directory. For security reasons, either make sure this directory can only be read by the server, or set secure_file_priv.
The lowest acceptable plugin maturity. MariaDB will not load plugins less mature than the specified level.
Connections will be blocked if they use the mysql_old_password authentication plugin.
--connect-expired-password
Notify the server that this client is prepared to handle expired password sandbox mode even if --batch was specified.
--default-auth=name
Default authentication client-side plugin to use.
--plugin-dir=path
Directory for client-side plugins.
--secure-auth
Refuse to connect to the server if the server uses the mysql_old_password authentication plugin. This mode is off by default, which is different from MySQL.
--auth-root-authentication-method={normal | socket}
If set to normal (the default), it creates a root@localhost account that authenticates with the mysql_native_password authentication plugin and that has no initial password set, which can be insecure. If set to socket, it creates a root@localhost account that authenticates with the unix_socket authentication plugin. Set to normal by default.
--auth-root-socket-user=USER
Used with --auth-root-authentication-method=socket. It specifies the name of the second account to create with SUPER privileges in addition to root, as well as of the system account allowed to access it. Defaults to the value of --user.
--plugin-dir=path
Directory for client-side plugins.
If set to 1 (0 is default), MariaDB reverts to using the mysql_old_password authentication plugin by default for newly created users and passwords, instead of the mysql_native_password authentication plugin.
Connections are blocked if they use the mysql_old_password authentication plugin.
--default-auth=name
Default authentication client-side plugin to use.
The MariaDB Enterprise Audit plugin logs detailed data access and configuration changes, offering advanced filtering to meet security and compliance requirements.
While application design specifications and database configurations may intend specific limitations to be placed around access to data, audit mechanisms help confirm the effectiveness of these controls.
MariaDB Enterprise Audit is a plugin that logs data access and database operations.
Audit mechanisms are most effective when they produce a manageable quantity of output. MariaDB Enterprise Audit includes advanced filtering features to enable narrowly defining which information is logged.
Where audit mechanisms may only be effective when control parameters can also be audited, MariaDB Enterprise Audit implements logging of configuration changes.
The PAM authentication plugin delegates password validation to the operating system's PAM framework, enabling integration with LDAP, Kerberos, and other services.
The pam authentication plugin allows MariaDB to offload user authentication to the system's framework. PAM is an authentication framework used by Linux, FreeBSD, Solaris, and other Unix-like operating systems.
Note: Windows does not support PAM, so the pam authentication plugin does not support Windows. However, one can use a MariaDB client on Windows to connect to MariaDB server that is installed on a Unix-like operating system and that is configured to use the pam
mysql_optionsv(mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
mysql_optionsv(mysql, MYSQL_DEFAULT_AUTH, "name");
mysql_optionsv(mysql, MYSQL_PLUGIN_DIR, "path");
mysql_optionsv(mysql, MYSQL_SECURE_AUTH, 1);GRANT <privileges> ON <level> TO <user>
IDENTIFIED VIA <plugin> [ USING <string> ]CREATE USER <user>
IDENTIFIED VIA <plugin> [ USING <string> ]ALTER USER <user>
IDENTIFIED VIA <plugin> [ USING <string> ]CREATE USER mysqltest_up1
IDENTIFIED VIA mysql_native_password USING '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB';CREATE USER mysqltest_up1
IDENTIFIED BY PASSWORD '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB';CREATE USER mysqltest_up1
IDENTIFIED VIA pam USING 'mariadb';CREATE USER root@localhost
IDENTIFIED VIA unix_socket
OR mysql_native_password USING PASSWORD("verysecret");mysql_optionsv(mysql, MYSQL_PLUGIN_DIR, "path");ERROR 2059 (HY000): Authentication plugin 'dialog' cannot be loaded: /usr/lib/mysql/plugin/dialog.so: cannot open shared object file: No such file or directoryCREATE USER username@hostname;CREATE USER username@hostname IDENTIFIED BY 'notagoodpassword';mysql_optionsv(mysql, MYSQL_SECURE_AUTH, 1);mysql_optionsv(mysql, MYSQL_DEFAULT_AUTH, "name");$ mysql -uroot
MariaDB []> CREATE USER serg IDENTIFIED VIA unix_socket;
MariaDB []> CREATE USER monty IDENTIFIED VIA unix_socket;
MariaDB []> quit
Bye
$ whoami
serg
$ mysql --user=serg
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.2.0-MariaDB-alpha-debug Source distribution
MariaDB []> quit
Bye
$ mysql --user=monty
ERROR 1045 (28000): Access denied for user 'monty'@'localhost' (using password: NO)CREATE USER wlad IDENTIFIED VIA named_pipe;
CREATE USER monty IDENTIFIED VIA named_pipe;
quit
C:\>echo %USERNAME%
wlad
C:\> mysql --user=wlad --protocol=PIPE
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.12-MariaDB-debug Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> quit
Bye
C:\> mysql --user=monty --protocol=PIPE
ERROR 1698 (28000): Access denied for user 'monty'@'localhost'CREATE USER insecure IDENTIFIED VIA two_questions USING 'notverysecret';extern "C" char *mysql_authentication_dialog_ask(
MYSQL *mysql, int type, const char *prompt, char *buf, int buf_len)Plugin Conflict (MENT-316)
The MariaDB Enterprise Audit plugin (server_audit2.so) is incompatible with the older server_audit.so (v1) plugin. Running both can cause server instability or deadlocks.
If you are a new user: You can continue reading.
If you are migrating: You must remove the old v1 plugin. Please go directly to the Upgrades section for complete instructions.
MariaDB Enterprise Audit is installed and loaded by default. If you are unsure whether it is loaded on your system, you can confirm that the plugin is loaded.
To use MariaDB Enterprise Audit, the plugin must be configured:
Administrators must define Audit Filters to configure what MariaDB Enterprise Audit writes to the audit log. MariaDB Enterprise Audit supports two types of Audit Filters:
The Default Audit Filter is used for any user account that is not assigned a Named Audit Filter.
Named Audit Filters are assigned to specific user accounts.
Administrators can define Audit Filters to audit log activity using multiple types of filters:
Event Filters are used to enable or disable audit logging for specific types of operations performed by the user accounts assigned to the Audit Filter.
Logging Filters are used to enable or disable audit logging for the user accounts assigned to the Audit Filter.
Object Filters are used to enable or disable audit logging for specific databases or tables accessed by the user accounts assigned to the Audit Filter. Support for Object Filters was added in MariaDB Enterprise Server 10.6. Support for Object Filters was backported to ES 10.4.21-13 and ES 10.5.12-8.
Administrators must start audit logging.
MariaDB Enterprise Audit performs audit logging during typical operations of MariaDB Enterprise Server:
When a user connects, fails to connect, or disconnects, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the specific type of Connect Event.
When a user executes a query, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the specific type of Query Event and if the queried objects are not excluded by Object Filters.
When a query accesses a table, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the specific type of Table Event and if the table is not excluded by Object Filters.
When a query modifies the MariaDB Enterprise Audit configuration, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the .
When a user's contains a Logging Filter that disables audit logging, all audit logging for the user's activity will be skipped.
MariaDB Enterprise Audit writes audit log messages either to a dedicated audit log file or to the system log (syslog), depending on configuration.
Audit log messages that correspond to a query are logged when the query completes. If a query is executed in a transaction, the audit log messages that correspond to the query are logged when the individual query completes, not when the transaction completes. If the query fails, the audit log message is logged at time of failure.
Care must be taken when logging data for audit to maintain alignment to business requirements. Concerns include:
Queries should not be logged for tables containing Personally Identifiable Information (PII) or Sensitive PII (SPII) such as passwords, since audit log data is written unencrypted. Consider using Object Filters to exclude sensitive information from the audit log.
Backup of audit data should be performed at least as frequently as database backups.
Audit log data on database servers could be tampered with if the database server is compromised. Consider secure transmission of log data to a hardened and remote logging server.
Where audit data is mission-critical, it should be subject to controls, data protection, data retention, and highly-available storage as are used for other mission-critical data.
MariaDB Enterprise Audit comes preinstalled with MariaDB Enterprise Server, so no manual installation is required.
To verify that the plugin is installed:
Locate your server’s plugin directory.
When MariaDB Enterprise Server is running, you can find the directory by checking the value of the plugin_dir system variable.
Verify the server_audit2.so file—the shared library used by MariaDB Enterprise Audit—is present in your server’s plugin directory.
MariaDB Enterprise Audit is bundled with all MariaDB Enterprise Server distributions (binary tarball, DEB/RPM package tarball, and DEB/RPM packages). If you do not see the server_audit2.so file, verify that MariaDB Enterprise Server has been installed correctly.
MariaDB Enterprise Audit is enabled through the mariadb-enterprise.cnf configuration file, which is included by default with MariaDB Enterprise Server. This means manual loading is usually not required.
The mariadb-enterprise.cnf file activates MariaDB Enterprise Audit by configuring the plugin-load-add and server-audit options.
If your environment does not use mariadb-enterprise.cnf, you can enable MariaDB Enterprise Audit by adding the same options to your own configuration file.
To verify that MariaDB Enterprise Audit is installed, check the information_schema.PLUGINS table.
MariaDB Enterprise Audit is enabled through the mariadb-enterprise.cnf configuration file, which is included by default in MariaDB Enterprise Server. If your results differ from the example output above, verify that the mariadb-enterprise.cnf file specifies the plugin-load-add and server-audit options.
When MariaDB Enterprise Audit is installed and loaded, audit logging does not begin automatically. You must explicitly start it, either from the shell or through SQL.
Shell
SQL access is not required SUPER privilege is not required Configuration file can be version controlled.
SQL
Server restart is not required.
enable audit logging with MariaDB Enterprise Audit by setting the server_audit_logging system variable in a configuration file.
Alternatively, you can enable it dynamically with SET GLOBAL, which does not require a server restart.
To configure in a file:
1. Set the server_audit_logging system variable in the configuration file.
Restart MariaDB Enterprise Server:
If the server does not start, review the error log for details.
To confirm that audit logging is running, check the value of the Server_audit_active status variable using the SHOW GLOBAL STATUS statement.
Audit logging with MariaDB Enterprise Audit can be started by setting the server_audit_logging system variable with the SET GLOBAL statement, which requires the SUPER privilege.
Set the server_audit_logging system variable with the SET GLOBAL statement:
Confirm that audit logging is started by querying the Server_audit_active status variable with the SHOW GLOBAL STATUS statement:
When you modify a system variable dynamically using the SET GLOBAL statement, the change is not preserved after a server restart. To ensure audit logging automatically starts with the server, also configure the server_audit_logging system variable in a configuration file.
Confirm that audit logging is started by querying the Server_audit_active status variable with the SHOW GLOBAL STATUS statement:
Audit log buffering is controlled by these variables:
server_audit_file_buffer_size — This defines the size of the buffer. The default value is 0, meaning there's no buffering at all. Setting non-zero value enables the buffering with the buffer of the specified size aligned by 8192. The maximum value is 65536.
server_audit_sync_log_file — This flushes the buffer to the log file. While the log record is in the buffer, it cannot be seen in the log file. If there aren't many events to log, the time before records can be observed can be significant. You can issue this statement to force writing the buffer to the file, making sure not to miss recent records:
In a secure environment, MariaDB Enterprise Audit provides administrators with an audit trail of actions performed by users on the MariaDB Enterprise Server node. To protect the integrity of the audit trail, users should not be able to uninstall MariaDB Enterprise Audit. If the server-audit option is set to FORCE_PLUS_PERMANENT, MariaDB Enterprise Server will prevent MariaDB Enterprise Audit from being uninstalled:
When a user tries to uninstall MariaDB Enterprise Audit with the server-audit option set to FORCE_PLUS_PERMANENT, the operation fails with the ER_PLUGIN_IS_PERMANENT error code:
If you do not use mariadb-enterprise.cnf in your environment, you can configure MariaDB Enterprise Audit to forbid uninstallation by setting the server-audit option in your configuration file.
To confirm that MariaDB Enterprise Audit is configured to forbid uninstallation, query the information_schema.PLUGINS table:
If your output does not match the example output shown above, confirm that the mariadb-enterprise.cnf configuration file sets the server-audit option to FORCE_PLUS_PERMANENT.
Some specific server startup behavior is described in the sections below.
For examples of error messages that can appear in the MariaDB error log during server startup, see Messages in MariaDB Error Log.
MariaDB Enterprise Server can startup and handle traffic even if MariaDB Enterprise Audit is not installed or loaded. However, the specific behavior can be configured.
When the server-audit option is set to FORCE or FORCE_PLUS_PERMANENT, MariaDB Enterprise Server will fail to start if MariaDB Enterprise Audit can't be loaded.
The mariadb-enterprise.cnf configuration file included by default in MariaDB Enterprise Server sets the server-audit option to FORCE_PLUS_PERMANENT. As a consequence, MariaDB Enterprise Server forbids MariaDB Enterprise Audit from being uninstalled by default.
MariaDB Enterprise Audit attempts to load the Audit Filters during startup.
When MariaDB Enterprise Audit encounters errors in the Audit Filter definitions, MariaDB Enterprise Server will still start and load MariaDB Enterprise Audit. In this situation, an error will be written to the MariaDB error log and all Events for all objects will be audit logged.
When enabled, MariaDB Enterprise Audit logs designated Events that occur on a running instance of MariaDB Enterprise Server.
Additional audit practices should be established to cover:
Data backup controls.
System-level controls, including authentication, file system, and process execution.
Network-level controls.
Monitoring systems, including monitoring for audit logging.
Changes to user accounts (and the system table), which can necessitate changes to Audit Filters.
Filters are JSON objects that specify what you want MariaDB Enterprise Audit to monitor.
There are two types of filters:
The Default Audit Filter is used for all user accounts that are not assigned a Named Audit Filter. Only a single Default Audit Filter can be defined in the mysql.server_audit_filters system table, and it must be defined with the name default.
Named Audit Filters must be assigned to specific user accounts. Many Named Audit Filters can be defined in the mysql.server_audit_filters system table, and they must be defined with unique names. A Named Audit Filter can be assigned to a user account by inserting the user account details and the filter name into the mysql.server_audit_users system table.
The Default Audit Filter applies to all user accounts that do not have a specific Named Audit Filter assigned. Only one Default Audit Filter is allowed in the mysql.server_audit_filters system table, and it must be named default.
If you want to create a Default Audit Filter, you need to insert the details into the mysql.server_audit_filters system table. The name for the Default Audit Filter must be default and the rule should be designed to meet your audit logging requirements.
To create a Default Audit Filter:
Confirm that a Default Audit Filter does not already exist:
If a Default Audit Filter already exists, remove it:
Insert the details for the new Default Audit Filter into the mysql.server_audit_filters system table:
This example Audit Filter configures audit logging for all Connection Events and Write Table Events.
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
Reload the Audit Filters by setting the server_audit_reload_filters system variable to ON:
It is recommended to use the default filter to assure that any user is audited, also if not defined in the mysql.server_audit_users system table.
In some special cases you might want audits only to be enabled for the users in mysql.server_audit_users. In this case you should use the following default filter to disable logging for all other users.
Named Audit Filters must be assigned to specific user accounts.
Multiple Named Audit Filters can be defined in the mysql.server_audit_filters system table, and they must be defined with unique names. A Named Audit Filter can be assigned to a user account by inserting the user account details and the filter name into the mysql.server_audit_users system table.
To create a Named Audit Filter, insert a row with the Audit Filter's name and the rule into the mysql.server_audit_filters system table:
This example Audit Filter is defined with the name reporting, and it configures audit logging for Connection Events and Disconnection Events and for several types of Table Events. This example Audit Filter can be useful for read-only users since it does not log table reads, but it does log table writes and schema changes which are illegitimate activities for a read-only user.
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
For additional information on how to assign the Audit Filter to a user account, see "Assign a Named Audit Filter".
Named Audit Filters are only active when they are assigned to a specific user account.
To assign a Named Audit Filter to a user account:
Insert a row with the user account details and the Audit Filter's name into the mysql.server_audit_users system table:
This example statement assigns the reporting Audit Filter created in "Create a Named Audit Filter" to the reader@% user account.
Reload the Audit Filters by setting the server_audit_reload_filters system variable to ON:
MariaDB Enterprise Audit does not track changes to user accounts. If you delete or rename a user account, the change doesn't cascade to the Audit Filter. The Audit Filters must be updated manually.
There are two system tables for Audit Filters:
mysql.server_audit_filters
Audit Filter definitions with MariaDB Enterprise Audit
mysql.server_audit_users
Audit Filter assignments for user accounts with MariaDB Enterprise Audit.
You can query Audit Filters by querying the mysql.server_audit_filters system table.
The JSON objects can be made more human-readable by passing them to the JSON_DETAILED() or JSON_LOOSE() functions:
You can query user assignments for Named Audit Filters by joining the mysql.server_audit_filters and mysql.server_audit_users system tables.
The JSON objects can be made more human-readable by passing them to the JSON_DETAILED() or JSON_LOOSE() functions:
MariaDB Enterprise Audit caches its Audit Filters to improve performance. When you change an Audit Filter or an Audit Filter assignment in the system tables, you need to reload the Audit Filters for the changes to take effect.
To reload Audit Filters, set the server_audit_reload_filters system variable to ON with the SET GLOBAL statement, which requires the SUPER privilege:
When you set the server_audit_reload_filters system variable to ON, MariaDB Enterprise Audit reloads all Audit Filters and assignments to ensure that it is using the latest definitions. Afterward, it sets server_audit_reload_filters back to OFF.
For additional information on how to use the server_audit_reload_filters system variable, see "Default Audit Filter" and "Named Audit Filters".
MariaDB Enterprise Audit supports Event Filters in Audit Filters. Event Filters can be used to configure which Events you want to audit. Each Event refers to a different class of operation.
MariaDB Enterprise Audit defines multiple Event classes that can be used in Event Filters:
The Event classes are described in the sections below. Example audit logs for each Event class are shown in the sections below. For details about the audit log format, see Audit Log Format.
MariaDB Enterprise Audit implements Audit Config Events to help keep track of changes to the audit log configuration.
MariaDB Enterprise Audit logs Audit Config (AUDIT_CONFIG) Events in the following situations:
When one of MariaDB Enterprise Audit's system variables is changed with the SET GLOBAL statement, the change is logged.
When the audit log file is rotated, it is logged.
In the following output, three audit configuration events (AUDIT_CONFIG) and one query event (QUERY) are shown:
AUDIT_CONFIG events are always logged, so no configuration is required when audit logging is started.
MariaDB Enterprise Audit implements Connection Events to audit connection attempts, authentication failures, and user account changes that occur due to certain authentication plugins, such as pam.
MariaDB Enterprise Audit logs Connection Events in the following situations:
When a user successfully connects, it is logged with the CONNECT Event sub-class.
When a user disconnects, it is logged with the DISCONNECT Event sub-class.
When a user fails to connect, it is logged with the FAILED_CONNECT Event sub-class.
When an existing connection authenticates as a different user, it is logged with the CHANGE_USER Event sub-class.
When an authentication plugin changes to a proxy user, it is logged with the PROXY_CONNECT Event sub-class.
In the following output, multiple sub-classes of connection events (CONNECT, DISCONNECT, FAILED_CONNECT) are shown:
An event filter for connection events can be added to an Audit filter with the connect_event key, which supports the following values:
CONNECT
Records when the user connects to MariaDB Enterprise Server
DISCONNECT
Records when the user disconnects from MariaDB Enterprise Server
FAILED_CONNECT
Records when a user attempts to connect to MariaDB Enterprise Server, but the connection attempt fails due to authentication or similar issues
CHANGE_USER
Records when a user switches to a different user account
PROXY_CONNECT
Records proxy user connections. This Connection Event sub-class was added in ES10.4.17-10 and ES10.5.8-5.
ALL
Records all connection Events
This query defines a Named Audit Filter that specifies connection events:
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
MariaDB Enterprise Audit implements Query Events to audit the execution of a specific subset of SQL statements.
MariaDB Enterprise Audit logs Query Events in the following situations:
When a SQL statement is directly executed, it is logged with the QUERY event.
MariaDB Enterprise Audit does not log query events for SQL statements that are indirectly executed. For example, if an SQL statement is executed as part of a view, stored procedure, stored function, or trigger, the query will not be logged. If you want to audit all table accesses, including indirect table accesses, it is recommended to enable audit logging for Table Events in addition to query events.
This query shows one query event:
An event filter for query events can be added to an Audit Filter with the query_event key, which supports the following values:
DML
Records any SQL statements in the Data Manipulation Language subset, including SELECT, INSERT, UPDATE, and DELETE statements.
DDL
Records any SQL statements in the Data Definition Language subset, including CREATE TABLE and ALTER TABLE, as well as DROP TABLE and TRUNCATE operations.
DCL
Records any SQL statements in the Data Control Language subset, including GRANT and REVOKE.
DML_READ
Records SELECT statements in the Data Manipulation Language subset.
DML_WRITE
Records any SQL statements for writes in the Data Manipulation Language subset, including INSERT, UPDATE, and DELETE statements.
DML_NO_SELECT
Alias for DML_WRITE
For example, the following query defines a Named Audit Filter that specifies Query Events:
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
MariaDB Enterprise Audit supports Object Filters for Query Events.
MariaDB Enterprise Audit does not support Object Filters for Query Events.
MariaDB Enterprise Audit implements Table Events to audit when a table is accessed or modified.
MariaDB Enterprise Audit logs Table Events in the following situations:
When an operation reads from a table, it is logged with the READ Event sub-class.
When an operation writes to a table, it is logged with the WRITE Event sub-class.
When an operation creates a table, it is logged with the CREATE Event sub-class.
When an operation drops a table, it is logged with the DROP Event sub-class.
When an operation alters a table, it is logged with the ALTER Event sub-class.
When an operation renames a table, it is logged with the RENAME Event sub-class.
Table Events are logged when a table is accessed or modified directly or indirectly by a query. They complement Query Events very well, because the Query Event causes the raw query to be audit logged, and the Table Event causes all table operations to be audit logged. Both Query Events and Table Events are logged with the query ID, so each Table Event can easily be mapped to its corresponding Query Event. The combination of Query Events and Table Events can be useful when table operations can be hidden by views or triggers.
In the following example output, 6 sub-classes of Table Events are shown:
When a query uses the DELAYED keyword, it is executed by a system user. In this case, any Table Event associated with the query is written to the audit log with the user set to DELAYED. However, the Query Event associated with the query is written to the audit log with the original user:
When your application executes queries with the DELAYED keyword, it is recommended to enable audit logging for Query Events in addition to Table Events to ensure that the full details are logged.
If the query cache is enabled, READ Table Events may not be audit logged. If MariaDB Enterprise Audit detects that the query cache is enabled during startup, MariaDB Enterprise Audit writes the following message to the MariaDB error log:
An Event Filter for Table Events can be added to an Audit Filter with the table_event key, which supports the following values:
READ
Records read operations run on table objects, such as from a SELECT statement or an INSERT SELECT
WRITE
Records write operations run on table objects, such as INSERT or UPDATE statements
CREATE
Records any creation operations run on table objects, such as from a CREATE TABLE or CREATE SERVER.
DROP
Records any deletion operations run on table objects, such as DELETE or DROP TABLE.
ALTER
Records any modifications made on table objects, such as ALTER TABLE or ALTER USER.
RENAME
Records any renaming operations run on table objects, such as RENAME TABLE
For example, the following query defines a Named Audit Filter that specifies Table Events:
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
MariaDB Enterprise Audit supports Object Filters for Table Events.
MariaDB Enterprise Audit does not support Object Filters for Table Events.
MariaDB Enterprise Audit supports a special Logging Filter that can be used in Audit Filters to enable or disable audit logging for any users that are assigned the Audit Filter.
The Logging Filter can be added to an Audit Filter with the logging key, which supports the following values:
ON
Enables audit logging for this Audit Filter
OFF
Disables audit logging for this Audit Filter
For example, the following query defines a Default Audit Filter that enables logging for all Events for any user account without a Named Audit Filter:
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
Object Filters allow Audit Filters to be limited to specific databases and/or tables. Object Filters can be specified at different scopes:
An Object Filter can be specified for an entire Audit Filter
An Object Filter can be specified for a single Event for the Audit Filter
Object Filters are formatted as JSON objects, which are key-value pairs.
For Object Filters, the key in the key-value pair refers to the specific type of Object Filter. The following types of Object Filters are supported:
No
ignore_databases
When one or more databases are specified with the ignore_databases Object Filter key, the specified databases will not be audit logged. The ignore_databases Object Filter key is an alias for the ignore_tables Object Filter key, with the table identifier set to the wildcard character (*). The ignore_databases Object Filter key cannot be specified in the same Object Filter as the log_databases and log_tables Object Filter keys.
No
ignore_tables
When one or more tables are specified with the ignore_tables Object Filter key, the specified tables will not be audit logged. Table names must be provided in the form database.table. Wildcard characters (*) are allowed. The ignore_tables Object Filter key cannot be specified in the same Object Filter as the log_databases and log_tables Object Filter keys.
Yes
log_databases
When one or more databases are specified with the log_databases Object Filter key, the specified databases will be audit logged, and all other databases will not be audit logged. The log_databases Object Filter key is an alias for the log_tables Object Filter key, with the table identifier set to the wildcard character (*).
Yes
log_tables
The values in the key-value pair refer to iniobject names.
When the Object Filter only applies to one object, the object name can be specified as a string scalar value in the JSON object:
When the Object Filter applies to multiple objects, the object names can be specified in a JSON array in the JSON object:
In the following example, the Object Filter is designed to audit log the production and reporting databases and to skip audit logging for all other databases and tables:
And in the following example, the Object Filter is designed to skip audit logging for the production.app_log table:
The Object Filter keys must be specified in different locations in the Audit Filter's JSON object, depending on the desired scope of the Object Filter. The following sections describe how to set Object Filters in more detail.
An Object Filter can be specified for a single Event Filter within an Audit Filter.
Object Filters are supported by the following Events:
To create an Object Filter for a single Event Filter, specify the Object Filter's JSON object as part of the JSON object for the Event Filter.
The examples below pass the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
In the following example, the reporting Audit Filter specifies an Event Filter for Table Events with an embedded Object Filter that includes all tables in the production and reporting databases:
An Object Filter can be specified for an entire Audit Filter.
To create an Object Filter at Audit Filter scope, specify the Object Filter's JSON object as part of the root JSON object for the Audit Filter.
The examples below pass the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
In the following example, the reporting Audit Filter specifies an Object Filter that includes all tables in the production and reporting databases:
When an Object Filter is specified at Audit Filter scope, it can contain embedded Event Filters. The following Event types support Object Filters:
In the following example, the reporting Audit Filter has been modified to include Event Filters on specific Query Event sub-classes and Table Event sub-classes:
When an Object Filter is specified at Audit Filter scope with embedded Event Filters, the embedded Event Filters can contain additional Object Filters. When you combine Object Filters at different levels, it is possible to combine Object Filters that are normally incompatible, like tables and ignore_tables.
To create Object Filters at Audit Filter and Event Type scope, specify the JSON object for the Object Filter at Audit Filter scope as part of the root JSON object for the Audit Filter and specify the JSON object for the Object Filter at Event Type scope as part of the JSON object for the Event Filter.
The examples below pass the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
In the following example, the reporting Audit Filter specifies an Event Filter for Table Events with an embedded Object Filter that includes all tables in the production and reporting databases, but it excludes Query Events that target specific tables that store Personally Identifiable Information (PII), so that the sensitive information does not appear in the audit log:
MariaDB Enterprise Audit writes audit log messages either to a dedicated audit log file or to the system log (syslog), depending on configuration.
The audit log destination is configured with the dit_output_type|server_audit_output_type system variable:
Audit log messages are written to a dedicated file.
Audit log messages are written to the system log (syslog).
MariaDB Enterprise Audit writes audit log messages to a dedicated audit log file when the dit_output_type|server_audit_output_type system variable is set to FILE.
The path to the dedicated audit log file is configured with the server_audit_file_path system variable. The path can be a relative or absolute path. If it is a relative path, then it will be relative to the datadir. For example, to set the path to mariadb-enterprise-audit.log with the SET GLOBAL statement:
When a system variable is dynamically changed with the SET GLOBAL statement, the change does not survive server restarts. To ensure that the new path is used when the server restarts, set the server_audit_file_path system variable in a configuration file:
When MariaDB Enterprise Audit is configured to use the dedicated audit log file, it can rotate the file.
The file is rotated when its size exceeds the size specified by the server_audit_file_rotate_size system variable. For example, to set the maximum log size to 2 GB with the SET GLOBAL statement:
When a system variable is dynamically changed with the SET GLOBAL statement, the change does not survive server restarts. To ensure that the new file rotation size is used when the server restarts, set the server_audit_file_rotate_size system variable in a configuration file:
The file can also be rotated manually by setting the server_audit_file_rotate_now system variable to ON. For example, to rotate the log with the SET GLOBAL statement:
MariaDB Enterprise Audit writes audit log messages to the system log (syslog) when the server_audit_output_type system variable is set to SYSLOG.
It can be very useful to configure audit logging to the syslog when your system's syslog is configured to securely transmit logs to a remote syslog server.
Several syslog parameters can be changed for MariaDB Enterprise Audit by setting the following system variables:
The audit log format for MariaDB Enterprise Audit depends on the audit log destination.
When MariaDB Enterprise Audit is configured to use a dedicated audit log file, it uses the following format for each line:
When MariaDB Enterprise Audit is configured to use the syslog, it uses the following format for each line:
MariaDB Enterprise Audit writes messages to the MariaDB Error Log in various scenarios. Some of the scenarios and log messages are described below.
When MariaDB Enterprise Server loads the plugin for MariaDB Enterprise Audit, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
For additional information, see "Load the Audit Plugin".
When MariaDB Enterprise Server unloads the plugin for MariaDB Enterprise Audit, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
The plugin is unloaded when MariaDB Enterprise Server is shutdown, so this message is most commonly written to the MariaDB error log during the shutdown process.
When audit logging is started and it is directed to a file, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
If a custom audit log path is configured, then the message will refer to the custom path.
For additional information, see "Start Audit Logging" and "Audit Logging to File".
When audit logging is started and it is directed to syslog, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
For additional information, see "Start Audit Logging" and "Audit Logging to Syslog".
When audit logging is stopped, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
When audit logging is changed to a file, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
For additional information, see "Audit Logging to File".
When audit logging is changed to syslog, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
For additional information, see "|mariadb-enterprise-audit/#audit-logging-to-system-logAudit Logging to Syslog".
When the file name for audit logging is changed, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
For additional information, see "Audit Log Path".
When the Audit Filters are reloaded and one or more of the Audit Filters are invalid, MariaDB Enterprise Audit writes the following message in the MariaDB error log:
For additional information, see "Reload Audit Filters and Assignments".
If the query cache is enabled, READ Table Events may not be audit logged. If MariaDB Enterprise Audit detects during startup that the query cache is enabled, MariaDB Enterprise Audit writes the following message to the MariaDB error log:
MariaDB Enterprise Audit is included with MariaDB Enterprise Server. Special consideration is needed when upgrading from MariaDB releases that include the MariaDB Audit Plugin, including MariaDB Community.
For details on how to upgrade from the MariaDB Audit Plugin to MariaDB Enterprise Audit, see the sections below.
Migrating from MariaDB Audit Plugin (v1)
MariaDB Enterprise Audit (server_audit2.so) is a different and incompatible plugin from the older MariaDB Audit Plugin (v1, server_audit.so) found in Community Server or older Enterprise Server versions.
The v1 plugin is configured with server variables (e.g., server_audit_events).
The Enterprise (v2) plugin is configured with system tables (e.g., mysql.server_audit_filters).
You must uninstall the v1 plugin before using the v2 plugin, as running both can cause server instability or deadlocks (). The following sections guide you through the full migration process, starting with checking for and removing the old plugin.
To confirm that the MariaDB Audit plugin is loaded, query the information_schema.PLUGINS table:
If you see the output shown above, then the MariaDB Audit plugin is installed, and it must be uninstalled prior to performing the upgrade or migration. Follow the instructions in the section below.
If you do not see any rows in the output, then the MariaDB Audit plugin is not installed.
The MariaDB Audit plugin has multiple uninstallation methods. You must choose the uninstallation method that corresponds to how the plugin was installed on your system.
To determine the uninstallation method, query the mysql.plugin system table:
If you see the output shown above, then the MariaDB Audit plugin can be uninstalled with UNINSTALL SONAME.
If you do not see any rows in the output, then the MariaDB Audit plugin call be uninstalled by editing the configuration file.
To uninstall the MariaDB Audit Plugin with UNINSTALL SONAME:
Check the plugin load option by querying the information_schema.PLUGINS table:
Check LOAD_OPTION column for FORCE_PLUS_PERMANENT
If the LOAD_OPTION column contains the value FORCE_PLUS_PERMANENT, then check your configuration files for the server-audit option:
If the server-audit option was found in a configuration file, then remove or comment the option out:
If the configuration file was changed, then restart the server:
Uninstall the plugin by executing the statement:
Confirm the plugin is uninstalled by querying the system table:
If the query returns no results, then the plugin has been uninstalled.
To uninstall the MariaDB Audit plugin with a configuration file:
Check your configuration files for the plugin_load_add option:
Remove or comment out the plugin_load_add option from the configuration file:
After upgrading to MariaDB Enterprise Server, execute mariadb-upgrade to create the System Tables for Audit Filters.
The MariaDB Audit Plugin defines Audit Filters using the server_audit_events system system variable, but MariaDB Enterprise Audit defines Audit Filters using the mysql.server_audit_filters system table.
If you are upgrading from the MariaDB Audit Plugin to MariaDB Enterprise Audit, perform the following procedure:
Remove or comment out lines involving the server_audit_events system variable from the configuration file:
Insert a replacement Audit Filter into the mysql.server_audit_filters system table:
The example passes the JSON object to the JSON_COMPACT() function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
The MariaDB Audit Plugin enables or disable audit logging for specific user accounts using the server_audit_incl_users and server_audit_excl_users system variables, but MariaDB Enterprise Audit uses the mysql.server_audit_users system table.
If you are upgrading from the MariaDB Audit Plugin to MariaDB Enterprise Audit, perform the following procedure:
Edit configuration file
Remove or comment out lines involving the server_audit_incl_users and server_audit_excl_users system variables from the configuration file:
For the server_audit_incl_users system variable
For any user account previously mentioned in the server_audit_incl_users system variable, determine if the user account can use the Default Audit Filter or if the user account requires a Named Audit Filter.
Insert the relevant Audit Filters into the mysql.server_audit_filters system table, and insert the user assignments into the mysql.server_audit_users system table:
The example passes the JSON object to the function, so that the JSON object is compacted prior to being inserted into the system table. This step is recommended, but not required.
For the system variable
For any user account previously mentioned in the system variable, create a that acts as an exclusion filter.
Insert the relevant Audit Filters into the mysql.server_audit_filters system table, and insert the user assignments into the mysql.server_audit_users system table:
This page is: Copyright © 2025 MariaDB. All rights reserved.
PAM makes it possible to implement various authentication scenarios of different complexity:
Authentication using passwords from /etc/shadow (this is what a default PAM configuration usually does). See the pam_unix PAM module.
Authentication using LDAP. See the pam_ldap PAM module.
Authentication using Microsoft's Active Directory. See the pam_lsass, pam_winbind, and pam_centrifydc PAM modules.
Authentication using one-time passwords (even with SMS confirmation!). See the and PAM modules.
Authentication using SSH keys. See the PAM module.
User and group mapping. See the PAM module.
Combining different authentication modules in interesting ways in a .
Password expiration.
Limiting access by time, date, day of the week, etc. See the PAM module.
Logging of every login attempt.
The pam authentication plugin's library is provided in binary packages in all releases on Linux.
Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.
The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:
The second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:
The auth_pam shared library actually refers to version 2.0 of the pam authentication plugin. Version 1.0 of the plugin as the auth_pam_v1 shared library is also available.
If you need to install version 1.0 of the authentication plugin instead of version 2.0, install it with INSTALL SONAME or INSTALL PLUGIN:
Alternatively, specify it in a relevant server option group in an option file:
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:
If you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, those options must be removed to prevent the plugin from being loaded the next time the server is restarted.
If you installed version 1.0 of the authentication plugin, you can uninstall it by executing a similar statement for auth_pam_v1:
The pam authentication plugin tells MariaDB to delegate the authentication to the PAM authentication framework. How exactly that authentication is performed depends on how PAM is configured.
PAM is divided into services. PAM services are configured by PAM configuration files. Typically, the global PAM configuration file is located at /etc/pam.conf and PAM directory-based configuration files for individual services are located in /etc/pam.d/.
If you want to use a PAM service called mariadb for your MariaDB PAM authentication, then the PAM configuration file for that service would also be called mariadb, and it would typically be located at /etc/pam.d/mariadb.
For example, here is a minimal PAM service configuration file that performs simple password authentication with UNIX passwords:
Let's breakdown this relatively simple PAM service configuration file.
Each line of a PAM service configuration file has the following general format:
It instructs the PAM authentication framework that for successful authentication (i.e. type=auth), it is required that the pam_unix.so PAM module returns a success. It also instructs the PAM authentication framework that for an account (i.e. type=account) to be valid, it is required that the pam_unix.so PAM module returns a success.
PAM also supports session and password types, but MariaDB's pam authentication plugin does not support those.
The above PAM service configuration file also provides the audit module argument to the pam_unix PAM module. The pam_unix manual says that this module argument enables extreme debug logging to the syslog.
On most systems, you can find many other examples of PAM service configuration files in your /etc/pam.d/ directory.
If you configure PAM to use the pam_unix PAM module (as in the above example), then you might notice on some systems that this will fail by default with errors like the following:
The problem is that on some systems, the pam_unix PAM module needs access to /etc/shadow in order to function, and most systems only allow root to access that file by default.
Newer versions of PAM do not have this limitation, so you may want to try upgrading your version of PAM to see if that fixes the issue.
If that does not work, then you can work around this problem by giving the user that runs mysqld access to /etc/shadow. For example, if the mysql user runs mysqld, then you could do the following:
After configuring, you have to restart the server. The server should now be able to read /etc/shadow.
The pam authentication plugin uses a setuid wrapper to perform its PAM checks, so it should not need any special workarounds to perform privileged operations, such as reading /etc/shadow when using the pam_unix PAM module. See MDEV-7032 for more information.
To create a user in MariaDB which uses the pam authentication plugin, execute CREATE USER while specifying the name of the plugin in the IDENTIFIED VIA clause:
If SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user this way with GRANT:
You can also specify a PAM service name for MariaDB to use by providing it with the USING clause:
This line creates a user that needs to be authenticated via the pam authentication plugin using the PAM service name mariadb. As mentioned in a previous section, this service's configuration file will typically be present in /etc/pam.d/mariadb.
If no service name is specified, then the plugin will use mysql as the default PAM service name.
For clients that use the libmysqlclient or libraries, MariaDB provides two client authentication plugins that are compatible with the pam authentication plugin:
dialog
mysql_clear_password
When connecting with a client or utility to a server as a user account that authenticates with the pam authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:
Both the dialog and the mysql_clear_password client authentication plugins transmit the password to the server in clear text. Therefore, when you use the pam authentication plugin, it is very important to encrypt client connections using TLS to prevent the clear-text passwords from being seen by unauthorized users.
Usually the pam authentication plugin uses the dialog client authentication plugin to communicate with the user. This client authentication plugin allows MariaDB to support arbitrarily complex PAM configurations with regular or one-time passwords, challenge-response, multiple questions, or just about anything else. When using a MariaDB client library, there is no need to install or enable anything — the dialog client authentication plugin is loaded by the client library completely automatically and transparently for the application.
The dialog client authentication plugin was developed by MariaDB, so MySQL's clients and client libraries as well as third party applications that bundle MySQL's client libraries do not support the dialog client authentication plugin out of the box. If the server tells an unsupported client to use the dialog client authentication plugin, then the client is likely to throw an error like the following:
For some libraries or applications, this problem can be fixed by copying dialog.so or dialog.dll from a MariaDB client installation that is compatible with the system into the system's MySQL client authentication plugin directory. However, not all clients are compatible with the dialog client authentication plugin, so this may not work for every client.
If your client does not support the dialog client authentication plugin, then you may need to use the mysql_clear_password client authentication plugin instead.
The dialog client authentication plugin transmits the password to the server in clear text. Therefore, when you use the pam authentication plugin, it is incredibly important to encrypt client connections using TLS to prevent the clear-text passwords from being seen by unauthorized users.
Users can instruct the pam authentication plugin to use the mysql_clear_password client authentication plugin instead of the dialog client authentication plugin by configuring the pam_use_cleartext_plugin system variable on the server. It can be set in a relevant server option group in an option file:
It is important to note that the mysql_clear_password plugin has very limited functionality.
The mysql_clear_password client authentication plugin only supports PAM services that require password-based authentication.
The mysql_clear_password client authentication plugin also only supports PAM services that ask the user a single question.
If the PAM service requires challenge-responses, multiple questions, or other similar complicated authentication schemes, then the PAM service is not compatible with mysql_clear_password client authentication plugin. In that case, the dialog client authentication plugin will have to be used instead.
The mysql_clear_password client authentication plugin transmits the password to the server in clear text. Therefore, when you use the pam authentication plugin, it is incredibly important to encrypt client connections using TLS to prevent the clear-text passwords from being seen by unauthorized users.
The mysql_clear_password client authentication plugin is similar to MySQL's mysql_clear_password client authentication plugin.
The mysql_clear_password client authentication plugin is compatible with MySQL clients and most MySQL client libraries, while the dialog client authentication plugin is not always compatible with them. Therefore, the mysql_clear_password client authentication plugin is most useful if you need some kind of MySQL compatibility in your environment, but you still want to use the pam authentication plugin.
Even though the mysql_clear_password client authentication plugin is compatible with MySQL clients and most MySQL client libraries, the mysql_clear_password client authentication plugin may be disabled by default by these clients and client libraries. For example, MySQL's version of the mysql command-line client has the --enable-cleartext-plugin option that must be set in order to use the mysql_clear_password client authentication plugin:
Other clients may require other methods to enable the authentication plugin. For example, MySQL Workbench has a checkbox titled Enable Cleartext Authentication Plugin under the Advanced tab on the connection configuration screen.
For applications that use MySQL's libmysqlclient, the authentication plugin can be enabled by setting the MYSQL_ENABLE_CLEARTEXT_PLUGIN option with the mysql_options() function:
For MySQL compatibility, also allows applications to set the MYSQL_ENABLE_CLEARTEXT_PLUGIN option with the function. However, this option does not actually do anything in , because the mysql_clear_password client authentication plugin is always enabled for MariaDB clients and client libraries.
supports pam authentication using the client authentication plugins, regardless of the value of the pam_use_cleartext_plugin system variable.
supports pam authentication using the client authentication plugins, regardless of the value of the pam_use_cleartext_plugin system variable.
supports pam v1 authentication, regardless of the value of the pam_use_cleartext_plugin system variable.
supports pam v2 authentication, regardless of the value of the pam_use_cleartext_plugin system variable.
supports pam authentication, regardless of the value of the pam_use_cleartext_plugin system variable.
supports pam authentication, but only if the pam_use_cleartext_plugin system variable is enabled on the server.
Errors and messages from PAM modules are usually logged using the syslog daemon with the authpriv facility. To determine the specific log file where the authpriv facility is logged, you can check rsyslog.conf.
On RHEL, CentOS, Fedora, and other similar Linux distributions, the default location for these messages is usually /var/log/secure.
On Debian, Ubuntu, and other similar Linux distributions, the default location for these messages is usually /var/log/auth.log.
For example, the syslog can contain messages like the following when MariaDB's pam authentication plugin is configured to use the pam_unix PAM module, and the user enters an incorrect password:
MariaDB's pam authentication plugin can also log additional verbose debug logging to the error log. This is only done if the plugin is a and if pam_debug is set.
The output looks like this:
The pam_exec PAM module can be used to implement some custom logging. This can be very useful when debugging certain kinds of issues.
Consider creating a script that writes the log output:
Change the PAM service configuration to execute the script using the pam_exec PAM module:
Whenever the above PAM service is used, the output of the script is written to /tmp/pam_output.txt. It looks similar to this output:
Even when using the pam authentication plugin, the authenticating PAM user account still needs to exist in MariaDB, and the account needs to have privileges in the database. Creating these MariaDB accounts and making sure the privileges are correct can be a lot of work. To decrease the amount of work involved, some users would like to be able to map a PAM user to a different MariaDB user. For example, let’s say that alice and bob are both DBAs. It would be nice if each of them could log into MariaDB with their own PAM username and password, while MariaDB sees both of them as the same dba user. That way, there is only one MariaDB account to keep track of. See User and Group Mapping with PAM for more information on how to do this.
There are many PAM modules. The ones described below are the ones that have been seen most often by MariaDB.
The pam_unix PAM module provides support for Unix password authentication. It is the default PAM module on most systems.
For a tutorial on setting up PAM authentication and user or group mapping with Unix authentication, see Configuring PAM Authentication and User Mapping with Unix Authentication.
The pam_user_map PAM module was developed by MariaDB to support user and group mapping.
The pam_ldap PAM module provides support for LDAP authentication.
For a tutorial on setting up PAM authentication and user or group mapping with LDAP authentication, see Configuring PAM Authentication and User Mapping with LDAP Authentication.
This can also be configured for Active Directory authentication.
The pam_sss PAM module provides support for authentication with System Security Services Daemon (SSSD).
This can be configured for Active Directory authentication.
The pam_lsass PAM module provides support for Active Directory authentication. It is provided by PowerBroker Identity Services – Open Edition.
The pam_winbind PAM module provides support for Active Directory authentication. It is provided by winbindd from the samba suite.
This PAM module converts all provided user names to lowercase. There is no way to disable this functionality. If you do not want to be forced to use all lowercase user names, then you may need to configure the pam_winbind_workaround system variable. See MDEV-18686 for more information.
The pam_centrifydc PAM module provides support for Active Directory authentication. It integrates with the commercial Active Directory Bridge from Centrify.
This can be configured for Active Directory authentication.
The pam_google_authenticator PAM module provides two-factor identification with Google Authenticator. It is from Google's google-authenticator-libpam open-source project. The PAM module should work with the open-source mobile apps built by Google's google-authenticator and google-authenticator-android projects as well as the closed source Google Authenticator mobile apps that are present in each mobile app store.
For an example of how to use this PAM module, see the blog post: MariaDB: Improve Security with Two-Step Verification.
The pam_securid PAM module provides support for multi-factor authentication. It is part of the commercial RSA SecurID Suite.
Note that current versions of this module are not safe for multi-threaded environments, and the vendor does not officially support the product on MariaDB. See MDEV-10361 about that. However, the module may work with a current version of MariaDB.
The pam_ssh PAM module provides authentication using SSH keys.
The pam_time PAM module provides time-controlled access.
MariaDB is a multi-threaded program, which means that different connections concurrently run in different threads. Current versions of MariaDB's pam authentication plugin execute PAM module code in the server address space. This means that any PAM modules used with MariaDB must be safe for multi-threaded environments. Otherwise, if multiple clients try to authenticate with the same PAM module in parallel, undefined behavior can occur. For example, the pam_fprintd PAM module is not safe for multi-threaded environments, and if you use it with MariaDB, you may experience server crashes.
The pam authentication plugin isolates PAM module code from the server address space, so even PAM modules that are known to be unsafe for multi-threaded environments should not cause issues with MariaDB. See MDEV-15473 for more information.
When a password validation plugin is enabled, MariaDB won't allow an account to be created if the password validation plugin says that the account's password is too weak. This creates a problem for accounts that authenticate with the pam authentication plugin, since MariaDB has no knowledge of the user's password. When a user tries to create an account that authenticates with the pam authentication plugin, the password validation plugin would throw an error, even with strict_password_validation=OFF set.
The workaround is to uninstall the password validation plugin with UNINSTALL PLUGIN, and then create the account, and then reinstall the password validation plugin with INSTALL PLUGIN:
Accounts that authenticate with the pam authentication plugin should be exempt from password validation checks. See MDEV-12321 and MDEV-10457 for more information.
SELinux may cause issues when using the pam authentication plugin. For example, using pam_unix with the pam authentication plugin while SELinux is enabled can sometimes lead to SELinux errors involving unix_chkpwd, such as the following::
Sometimes issues like this can be fixed by updating the system's SELinux policies. You may be able to update the policies using audit2allow. See SELinux: Generating SELinux Policies with audit2allow for more information.
If you can't get the pam authentication plugin to work with SELinux at all, then it can help to disable SELinux entirely. See SELinux: Changing SELinux's Mode for information on how to do this.
You may run into authentication failures with the following log message in the MariaDB error log:
This can happen on operating system setups that are configured to prevent memory overcommit. When the MariaDB server process spawns the auth_pam_tool helper process there's a brief period where the new process inherits the memory of the MariaDB process before releasing that memory and executing the new command. When having a MariaDB server configured to use more than 50% of the server machine's RAM — which is common for dedicated database servers — this duplication would lead to an over-commit situation.
Current MariaDB version use posix_spawn() instead of the classic fork();exec() to prevent memory overcommit issues. However, operating systems with older glibc versions (< 2.26) still use fork();exec() to implement posix_spawn() internally. Therefore, they are still affected; this is for example still the case on RedHat Enterprise Linux 7.
Older MariaDB versions still use fork();exec() , which means they are affected by the memory overcommit issue.
To solve this you can do this:
Change the vm.overcommit_memory kernel setting to allow memory overcommit.
Alternatively, install the older auth_pam_v1 plugin version that does not spawn a helper process (but may run into problems with file permissions or multi threading with some PAM modules).
See also MDEV-26212 and MDEV-3073.
Description: Enables verbose debug logging to the error log for all authentication handled by the plugin.
This system variable is only available when the plugin is a .
Command line: --pam-debug
Scope: Global
Dynamic: No
Data Type: boolean
Default Value: OFF
Introduced: MariaDB 10.2.2, MariaDB 10.1.17
Description: Use the mysql_clear_password client authentication plugin instead of the dialog client authentication plugin. This may be needed for compatibility reasons, but it only supports simple PAM configurations that don't require any input besides a password.
Command line: --pam-use-cleartext-plugin
Scope: Global
Dynamic: No
Data Type: boolean
Default Value: OFF
Introduced: MariaDB 10.1.1, MariaDB 5.5.32
Description: Configures the authentication plugin to compare the user name provided by the client with the user name returned by the PAM module in a case insensitive manner. This may be needed if you use the pam_winbind PAM module, which is known to convert all user names to lowercase, and which does not allow this behavior to be disabled.
Command line: --pam-winbind-workaround
Scope: Global
Dynamic: Yes
Data Type: boolean
Default Value: OFF
Introduced: MariaDB 10.4.5, MariaDB 10.3.15, MariaDB 10.2.24, MariaDB 10.1.39
Description: Controls how the server should treat the plugin when the server starts up.
Valid values are:
OFF - Disables the plugin without removing it from the mysql.plugins table.
ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.
FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.
FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with or while the server is running.
See for more information.
Command line: --pam=value
Data Type: enumerated
Default Value: ON
Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT
This page is licensed: CC BY-SA / Gnu FDL
SELECT PLUGIN_STATUS, PLUGIN_LIBRARY, PLUGIN_DESCRIPTION, LOAD_OPTION
FROM information_schema.PLUGINS
WHERE PLUGIN_NAME='SERVER_AUDIT'\G*************************** 1. row ***************************
PLUGIN_STATUS: ACTIVE
PLUGIN_LIBRARY: server_audit.so
PLUGIN_DESCRIPTION: Audit the server activity
LOAD_OPTION: FORCE_PLUS_PERMANENT$ grep --extended-regexp --with-filename \
'plugin[-_]load[-_]add[[:blank:]]*=[[:blank:]]*server_audit' \
/etc/mysql/my.cnf \
/etc/mysql/mariadb.conf.d/*/etc/mysql/mariadb.conf.d/enable-audit.cnf:plugin_load_add=server_audit[mariadb]
# plugin_load_add=server_audit[mariadb]
...
# server_audit_events=CONNECT,QUERYINSERT INTO mysql.server_audit_filters
VALUES ('default',
JSON_COMPACT(
'{
"connect_event": "ALL",
"query_event": "ALL"
}'
));[mariadb]
...
# server_audit_incl_users = root,app
# server_audit_excl_users = backup_user,monitor_userSHOW GLOBAL VARIABLES
LIKE 'plugin_dir';+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| plugin_dir | /usr/lib64/mysql/plugin/ |
+---------------+--------------------------+$ ls -l /usr/lib64/mysql/plugin/server_audit2.so-rwxr-xr-x. 1 root root 70432 Jul 15 19:03 /usr/lib64/mysql/plugin/server_audit2.so# -- Auditing - pre-load Plugin
plugin-load-add=server_audit
server_audit=FORCE_PLUS_PERMANENTSELECT PLUGIN_STATUS, PLUGIN_LIBRARY, PLUGIN_DESCRIPTION, LOAD_OPTION
FROM information_schema.PLUGINS
WHERE PLUGIN_NAME='SERVER_AUDIT'\G*************************** 1. row ***************************
PLUGIN_STATUS: ACTIVE
PLUGIN_LIBRARY: server_audit2.so
PLUGIN_DESCRIPTION: MariaDB Enterprise Audit
LOAD_OPTION: FORCE_PLUS_PERMANENT[mariadb]
server_audit_logging = ON$ sudo systemctl restart mariadbSHOW GLOBAL STATUS
LIKE 'Server_audit_active';+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Server_audit_active | ON |
+---------------------+-------+SET GLOBAL server_audit_logging=ON;SHOW GLOBAL STATUS
LIKE 'Server_audit_active';+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Server_audit_active | ON |
+---------------------+-------+[mariadb]
server_audit_logging = ONSHOW GLOBAL STATUS
LIKE 'Server_audit_active';+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Server_audit_active | ON |
+---------------------+-------+SET GLOBAL server_audit_log_file=1server_audit=FORCE_PLUS_PERMANENTUNINSTALL SONAME 'server_audit2';ERROR 1702 (HY000): Plugin 'SERVER_AUDIT' is force_plus_permanent and can not be unloadedSELECT PLUGIN_STATUS, PLUGIN_LIBRARY, PLUGIN_DESCRIPTION, LOAD_OPTION
FROM information_schema.PLUGINS
WHERE PLUGIN_NAME='SERVER_AUDIT'\G*************************** 1. row ***************************
PLUGIN_STATUS: ACTIVE
PLUGIN_LIBRARY: server_audit2.so
PLUGIN_DESCRIPTION: MariaDB Enterprise Audit
LOAD_OPTION: FORCE_PLUS_PERMANENTSELECT * FROM mysql.server_audit_filters
WHERE filtername = 'default';DELETE FROM mysql.server_audit_filters
WHERE filtername = 'default';INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES ('default',
JSON_COMPACT(
'{
"connect_event":"ALL",
"table_event":"WRITE"
}'
));SET GLOBAL server_audit_reload_filters=ON;INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES ('default',
JSON_COMPACT(
'{
“logging”: “OFF”
}'
));INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES ('reporting',
JSON_COMPACT(
'{
"connect_event": [
"CONNECT",
"DISCONNECT"
],
"table_event":[
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER"
]
}'
));INSERT INTO mysql.server_audit_users (host, user, filtername)
VALUES ("%", "reader", "reporting");SET GLOBAL server_audit_reload_filters=ON;SELECT filtername,
JSON_DETAILED(rule)
FROM mysql.server_audit_filters\G*************************** 1. row ***************************
filtername: reporting
JSON_DETAILED(rule): {
"table_event":
[
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER",
{
"log_databases":
[
"production",
"reporting"
]
}
]
}SELECT sau.host, sau.user, saf.filtername,
JSON_DETAILED(saf.rule)
FROM mysql.server_audit_filters saf
JOIN mysql.server_audit_users sau
ON saf.filtername = sau.filtername
WHERE saf.filtername != 'default'\G*************************** 1. row ***************************
host: %
user: reader
filtername: reporting
JSON_DETAILED(saf.rule): {
"table_event":
[
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER",
{
"log_databases":
[
"production",
"reporting"
]
}
]
}
*************************** 2. row ***************************
host: %
user: writer
filtername: reporting
JSON_DETAILED(saf.rule): {
"table_event":
[
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER",
{
"log_databases":
[
"production",
"reporting"
]
}
]
}SET GLOBAL server_audit_reload_filters=ON;20190622 02:10:21,localhost.localdomain,,,0,0,AUDIT_CONFIG,,file_path=server_audit.log,0
20190622 02:10:21,localhost.localdomain,,,0,0,AUDIT_CONFIG,,rotate_size=1000000,0
20190622 02:10:21,localhost.localdomain,,,0,0,AUDIT_CONFIG,,file_rotations=9,0
20190622 02:10:21,localhost.localdomain,root,localhost,8,7,QUERY,mysql,'set global server_audit_logging = on',020190710 00:05:30,localhost.localdomain,root, localhost,2,0,CONNECT,,,0
20190710 00:05:53,localhost.localdomain,root, localhost,2,0,DISCONNECT,,,0
20190710 00:06:28,localhost.localdomain,unknownuser,localhost,3,0,FAILED_CONNECT,,,1045
20190710 00:06:28,localhost.localdomain,unknownuser, localhost,3,0,DISCONNECT,,,0INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES ('connections',
JSON_COMPACT(
'{
"connect_event": [
"CONNECT",
"DISCONNECT"
]
}'
));20190710 02:21:07,localhost.localdomain,John,localhost,3,30,QUERY,db1,'SELECT * FROM services WHERE typeid IN (SELECT id FROM services_types WHERE name="consulting")',0INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'queries',
JSON_COMPACT(
'{
"query_event": [
"DML",
"DDL",
"DCL",
"DML_NO_SELECT",
"DML_WRITE",
"DML_READ",
"ALL"
]
}'
)
);20190710 02:21:06,localhost.localdomain,John,localhost,3,25,CREATE,db1,services,
20190710 02:21:06,localhost.localdomain,John,localhost,3,27,READ,db1,services,
20190710 02:21:07,localhost.localdomain,John,localhost,3,29,WRITE,db1,services,
20190710 02:21:27,localhost.localdomain,John,localhost,3,35,ALTER,db1,services,
20190710 02:21:27,localhost.localdomain,John,localhost,3,36,RENAME,db1,services,db1,services_new
20190710 02:21:45,localhost.localdomain,John,localhost,3,38,DROP,db1,services_new,20190622 02:10:21,localhost.localdomain,root,localhost,8,5,QUERY,test,'INSERT DELAYED INTO t1 VALUES(1),(2),(3);',0
20190622 02:10:25,localhost.localdomain,root,localhost,2,2,WRITE,test,t1,
20190622 02:10:25,localhost,DELAYED,localhost,2,2,WRITE,test,t1,2021-07-23 0:11:26 server_audit: Query cache is enabled with the TABLE events. Some table reads can be veiled.INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'tables',
JSON_COMPACT(
'{
"table_event": [
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER"
]
}'
)
);INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'default',
JSON_COMPACT(
'{
"logging": "ON"
}'
)
);{"object_filter_key": "object"}{"object_filter_key": [ "object", "object" ]}{"log_tables": ["production.*", "reporting.*"]}{"ignore_tables": "production.app_log"}INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'reporting',
JSON_COMPACT(
'{
"table_event": [
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER",
{
"log_tables": [
"production.*",
"reporting.*"
]
}
]
}'
)
);INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'reporting',
JSON_COMPACT(
'{
"log_tables": [
"production.*",
"reporting.*"
]
}'
)
);INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'reporting',
JSON_COMPACT(
'{
"log_tables": [
"production.*",
"reporting.*",
{
"query_event": [
"DML",
"DDL"
],
"table_event": [
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER"
]
}
]
}'
)
);INSERT INTO mysql.server_audit_filters (filtername, rule)
VALUES (
'reporting',
JSON_COMPACT(
'{
"log_tables": [
"production.*",
"reporting.*",
{
"table_event": [
"WRITE",
"CREATE",
"DROP",
"RENAME",
"ALTER"
],
"query_event": [
"DML",
"DDL",
{
"ignore_tables": [
"production.customer_profiles",
"production.customer_addresses"
]
}
]
}
]
}'
)
);SET GLOBAL server_audit_file_path = 'mariadb-enterprise-audit.log'[mariadb]
server_audit_file_path=mariadb-enterprise-audit.logSET GLOBAL server_audit_file_rotate_size = 2 * (1024 * 1024 * 1024);[mariadb]
...
server_audit_file_rotate_size=2147483648SET GLOBAL server_audit_file_rotate_now = ON;<timestamp>,<serverhost>,<username>,<host>,<connectionid>,<queryid>,<operation>,<database>,<object>,<retcode><timestamp> <syslog_host> <syslog_ident>: <syslog_info> <serverhost>,<username>,<host>,<connectionid>,<queryid>,<operation>,<database>,<object>,<retcode>2021-08-03 21:07:03 server_audit: MariaDB Audit Plugin version 2.0.3 STARTED.2021-08-02 23:54:59 server_audit: STOPPED2021-08-03 21:39:42 server_audit: logging started to the file server_audit.log.2021-08-03 22:02:45 server_audit: logging started to the syslog.2021-08-03 21:39:50 server_audit: logging was stopped.2021-08-03 22:03:31 server_audit: Output was redirected to 'file'2021-08-03 22:01:22 server_audit: Output was redirected to 'syslog'2021-08-03 22:05:17 server_audit: Log file name was changed to 'mariadb-enterprise-audit.log'.2021-08-03 21:51:55 server_audit: Unknown filter function tabels.
2021-08-03 21:51:55 server_audit: Can't parse filter's 'production' definition { "tabels": "production.*" }.
2021-08-03 21:51:55 server_audit: can't load filters - old filters are saved.2021-08-03 21:07:03 server_audit: Query cache is enabled with the TABLE events. Some table reads can be veiled.SELECT PLUGIN_STATUS, PLUGIN_LIBRARY, PLUGIN_DESCRIPTION
FROM information_schema.PLUGINS
WHERE PLUGIN_NAME='SERVER_AUDIT'\G*************************** 1. row ***************************
PLUGIN_STATUS: ACTIVE
PLUGIN_LIBRARY: server_audit.so
PLUGIN_DESCRIPTION: Audit the server activitySELECT *
FROM mysql.plugin
WHERE name = 'SERVER_AUDIT'\G*************************** 1. row ***************************
name: SERVER_AUDIT
dl: server_audit.soINSTALL SONAME 'auth_pam';[mariadb]
...
plugin_load_add = auth_pamINSTALL SONAME 'auth_pam_v1';[mariadb]
...
plugin_load_add = auth_pam_v1UNINSTALL SONAME 'auth_pam';UNINSTALL SONAME 'auth_pam_v1';auth required pam_unix.so audit
account required pam_unix.so audittype control module-path module-argumentsApr 14 12:56:23 localhost unix_chkpwd[3332]: check pass; user unknown
Apr 14 12:56:23 localhost unix_chkpwd[3332]: password check failed for user (alice)
Apr 14 12:56:23 localhost mysqld: pam_unix(mysql:auth): authentication failure; logname= uid=991 euid=991 tty= ruser= rhost= user=alicesudo groupadd shadow
sudo usermod -a -G shadow mysql
sudo chown root:shadow /etc/shadow
sudo chmod g+r /etc/shadowCREATE USER username@hostname IDENTIFIED VIA pam;GRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA pam;CREATE USER username@hostname IDENTIFIED VIA pam USING 'mariadb';mariadb --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=aliceERROR 2059 (HY000): Authentication plugin 'dialog' cannot be loaded: /usr/lib/mysql/plugin/dialog.so: cannot open shared object file: No such file or directory[mariadb]
...
pam_use_cleartext_pluginmysql --enable-cleartext-plugin --user=alice -pmysql_options(mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN, 1);Jan 9 05:35:41 ip-172-30-0-198 unix_chkpwd[1205]: password check failed for user (foo)
Jan 9 05:35:41 ip-172-30-0-198 mysqld: pam_unix(mariadb:auth): authentication failure; logname= uid=997 euid=997 tty= ruser= rhost= user=fooPAM: pam_start(mariadb, alice)
PAM: pam_authenticate(0)
PAM: conv: send(Enter PASSCODE:)
PAM: conv: recv(123456789)
PAM: pam_acct_mgmt(0)
PAM: pam_get_item(PAM_USER)
PAM: status = 0 user = ��\>tee /tmp/pam_log_script.sh <<EOF
#!/bin/bash
echo "\${PAM_SERVICE}:\${PAM_TYPE} - \${PAM_RUSER}@\${PAM_RHOST} is authenticating as \${PAM_USER}"
EOF
chmod 0775 /tmp/pam_log_script.shauth optional pam_exec.so log=/tmp/pam_output.txt /tmp/pam_log_script.sh
auth required pam_unix.so audit
account optional pam_exec.so log=/tmp/pam_output.txt /tmp/pam_log_script.sh
account required pam_unix.so audit*** Tue May 14 14:53:23 2019
mariadb:auth - @ is authenticating as alice
*** Tue May 14 14:53:25 2019
mariadb:account - @ is authenticating as alice
*** Tue May 14 14:53:28 2019
mariadb:auth - @ is authenticating as alice
*** Tue May 14 14:53:31 2019
mariadb:account - @ is authenticating as aliceINSTALL PLUGIN simple_password_check SONAME 'simple_password_check';
Query OK, 0 rows affected (0.002 sec)
SET GLOBAL strict_password_validation=OFF;
Query OK, 0 rows affected (0.000 sec)
CREATE USER ''@'%' IDENTIFIED VIA pam USING 'mariadb';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
UNINSTALL PLUGIN simple_password_check;
Query OK, 0 rows affected (0.000 sec)
CREATE USER ''@'%' IDENTIFIED VIA pam USING 'mariadb';
Query OK, 0 rows affected (0.000 sec)
INSTALL PLUGIN simple_password_check SONAME 'simple_password_check';
Query OK, 0 rows affected (0.001 sec)Apr 14 12:37:59 localhost setroubleshoot: Plugin Exception restorecon_source
Apr 14 12:37:59 localhost setroubleshoot: SELinux is preventing /usr/sbin/unix_chkpwd from execute access on the file . For complete SELinux messages. run sealert -l c56fe6e0-c78c-4bdb-a80f-27ef86a1ea85
Apr 14 12:37:59 localhost python: SELinux is preventing /usr/sbin/unix_chkpwd from execute access on the file .
***** Plugin catchall (100. confidence) suggests **************************
If you believe that unix_chkpwd should be allowed execute access on the file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep unix_chkpwd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pppam: cannot exec /usr/lib64/mysql/plugin/auth_pam_tool_dir/auth_pam_tool (errno: 12 "Cannot allocate memory")ALL
Records any SQL statements run by the user.
ALL
Records all operations run on table objects
When one or more databases are specified with the log_tables Object Filter key, the specified tables will be audit logged, and all other tables will not be audit logged. Table names must be provided in the form database.table. Wildcard characters (*) are allowed.
$ grep --extended-regexp --with-filename \
'server[-_]audit[[:blank:]]*=' \
/etc/mysql/my.cnf \
/etc/mysql/mariadb.conf.d/*/etc/mysql/mariadb.conf.d/enable-audit.cnf:server_audit=FORCE_PLUS_PERMANENT[mariadb]
# server_audit=FORCE_PLUS_PERMANENT$ sudo systemctl restart mariadbUNINSTALL SONAME 'server_audit';SELECT *
FROM mysql.plugin
WHERE name = 'SERVER_AUDIT'\GINSERT INTO mysql.server_audit_filters
VALUES
('default',
JSON_COMPACT(
'{
"connect_event": [
"CONNECT",
"DISCONNECT"
],
"query_event": [
"DML",
"DDL"
]
}'
)),
('root_filter',
JSON_COMPACT(
'{
"logging": "ON"
}'
));
INSERT INTO mysql.server_audit_users (host, user, filtername)
VALUES ('%', 'root', 'root_filter');INSERT INTO mysql.server_audit_filters
VALUES ('exclusion_filter',
JSON_COMPACT(
'{
"logging": "OFF"
}'
));
INSERT INTO mysql.server_audit_users (host, user, filtername)
VALUES
('%', 'backup_user', 'exclusion_filter'),
('%', 'monitor_user', 'exclusion_filter');