How to enable slow query log in MySQL/MariaDB

To enable MySQL slow query login, edit my.cnf file

For MariaDB, edit

Add

Restart MySQL

On CentOS, the command is “systemctl retstart mysqld”. If you are using MariaDB, use “systemctl restart mariadb”.

You can use mysqldumpslow command to view slow queries.

To test, you can run the command

This will simulate a query, that take 10 seconds.

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *