First enable the MySQL slow query log in the MySQL configuration file my.cnf
CentOS/RHEL Based
vi /etc/my.cnfDebian/Ubuntu Based
vi /etc/mysql/my.cnfAdd the records below at the end of the **mysqld** section:
[mysqld]
slow_query_log = 1
log-slow-queries = /var/log/mysql-slow.log
long_query_time = 1Create slow log file
# touch /var/log/mysql-slow.log
# chown mysql:mysql /var/log/mysql-slow.logRestart MySQL service
CentOS/RHEL
service mysqld restartDebian/Ubuntu
service mysql restartIf MariaDB installed
service mariadb restartTail the slow log file
tail -f /var/log/mysql-slow.log