Script for trace session in MySQL or MariaDB

In some cases, we cannot trace the session by enabling a general log. If we cannot enable the general log like in the AWS cloud. We have to restart the database by changing the parameter setting. So that we try to create a script that will try to get the information from the information_schema.processlist table by continue executing the command.

Note: It’s not a good or 100% result-giving method but it’s an alternative if we are not able to enable the general log method in MySQL or MariaDB.

Script for tracing session:


cd c:\Program Files\MariaDB10.6\bin
:top
mysql -u root --password=password -h hostname --database dbname --execute="select * from information_Schema.processlist where info is not null"  >> C:\test\output.txt
goto top
This entry was posted in MySQL on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply