Trace the SQL Queries in MariaDB

For trace, the Queries executing from the application side in MariaDB provides a general_log parameter for enabling and disabling the traces.

Check status of General Log

SELECT @@general_log;

For Enable the trace of SQL Queries:

SET GLOBAL general_log=1;

For Disable the trace of SQL Queries:

set global general_log=0;

Check and change the general log output as FILE or TABLE

-- Check the log file output format:
select @@log_output
@@log_output|
------------+
FILE        |

Check the file location:
SELECT @@general_log_file;
@@general_log_file|
------------------+
AD3-BBAAAKKK2.log |

--Change the log file format to TABLE:
SET GLOBAL log_output='TABLE';

Check the table for Log generation or SQL traces:

select * from mysql.general_log;

--Empty the table if no need
truncate table mysql.general_log;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.