Monitor all queries to MariaDB

Want to see what is being run against your MariaDB this is what to do.

Firstly you need to enable logging to a file of all queries. You do this by running:

SET GLOBAL general_log=1;
SET GLOBAL general_log_file=’/var/opt/rh/rh-mariadb102/log/mariadb/maria_general.log’;

Problem is you need special permissions and in practical terms the easiest way is to run it as the root MariaDB user on the host machine. So login to the host machine and run this

mysql -u root -p
SET GLOBAL general_log=1;
SET GLOBAL general_log_file=’/var/opt/rh/rh-mariadb102/log/mariadb/maria_general.log’;
COMMIT;

I am not sure if the COMMIT; is required, I have only added it because I added it to be sure.

You can also enable this functionality by adding parameters to the startup command of MariaDB

Posted in MariaDB, MySQL Tagged , , permalink
Tony

About Tony

I believe in putting back and my contribution to this site and my blog is about adding information that I think is useful and different. It's also about adding my slant to life with things I see and views I have on subjects.