SQL Error Log Plugin
The SQL_ERROR_LOG plugin collects errors sent to clients in a log file defined by sql_error_log_filename, so that they can later be analyzed. The log file can be rotated if sql_error_log_rotate is set.
Errors are logged as they happen and an error will be logged even if it was handled by a condition handler and was never technically sent to the client.
From MariaDB 10.11.5 warnings can also be logged if sql_error_log_warnings is enabled.
Comments are also logged, which can make the log easier to search. But this is only possible if the client does not strip the comments away. For example, the mariadb command-line client only leaves comments when started with the --comments option.
Installing the Plugin
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. For example:
INSTALL SONAME 'sql_errlog';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. For example:
[mariadb]
...
plugin_load_add = sql_errlogUninstalling the Plugin
You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN. For example:
UNINSTALL SONAME 'sql_errlog';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.
Logging
The log format until MariaDB 10.10 is:
Starting from MariaDB 10.11, the format is:
Starting from MariaDB 10.6.17, MariaDB 10.11.7, MariaDB 11.0.5, MariaDB 11.1.4, MariaDB 11.2.3, MariaDB 11.3.2, and MariaDB 11.4.1, when the sql_error_log_with_db_and_thread_info variable is enabled, the log also contains thread id and database name. If there is no database, NULL will be displayed.
Each separated by a space or : as above
Time
Time (YYYY-MM-DD hh-mm-ss)
5.5.22
Thread Id
Thread Id of current thread
10.6.17
User
privilege_user [login_user_name] @ hostname [ip]
5.5.22
Database name
Name of the currently selected database
10.6.17
Type
ERROR or WARNING
10.11.6
Error_code
OS error, MariaDB storage engine code (120-199) or MariaDB internal error code (1000-)
5.5.22
Query
Query text
5.5.22
Example of Logs
With sql_error_log_with_db_and_thread_info enabled (database test and thread id 4):
Example Usage
Versions
System Variables and Options
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

