SQL error log plugin in MariaDB, sql_errlog

  • Last update: Apr 3, 2024
  • Views: 31
  • Author: Admin
SQL error log plugin in MariaDB, sql_errlog

Hello colleagues.

In today's article, I will tell you about such a plugin as sql_errlog in MariaDB. With this plugin, you can register sql errors, errors will be written to a special file that we specify. Errors are logged as they occur. Although the plugin's shared library is distributed with MariaDB by default, this plugin is not actually installed by MariaDB by default.

 

The content of the article:

  1. Plugin installation.
  2. Creating a directory for the magazine.
  3. Plugin setup.
  4. Examination.

 

1. Plugin installation.

To install the plugin, use the command:

MariaDB [(none)]> INSTALL SONAME 'sql_errlog';

The plugin has been successfully installed.


 

2. Creating a directory for the magazine.

$. sudo mkdir -p /app/mariadb/sql_error

$. sudo chown -R mysql:mysql /app/mariadb/sql_error


 

3. Plugin setup.

We will use these options:

  • sql_error_log_filename - The name of the log file.
  • sql_error_log_size_limit - Log file size limit. After the specified limit is reached, the log file is rotated. The 1M limit is set by default.
  • sql_error_log_rate - Logging speed

 

Go to the server.cnf configuration file in the /etc/my.cnf.d directory and configure these settings.

$. sudo vim /etc/my.cnf.d/server.cnf

Save and close.

With these parameters we indicate that the error file will be called mariadb-sql-error.err, its maximum size will be 512M, after reaching this size it will be overwritten, and the last parameter we specified is that absolutely all sql errors are logged.

 

We restart the database.

$. sudo service mariadb restart


 

4. Example.

I was trying to create table foo2 with ENGINE WHOOPSIE which doesn't exist and this error was written to a file.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES