First enable the MySQL slow query log in the MySQL configuration file my.cnf

CentOS/RHEL Based

vi /etc/my.cnf

Debian/Ubuntu Based

vi /etc/mysql/my.cnf

Add the records below at the end of the **mysqld** section:

slow_query_log = 1
log-slow-queries = /var/log/mysql-slow.log
long_query_time = 1

Create slow log file

# touch /var/log/mysql-slow.log
# chown mysql:mysql /var/log/mysql-slow.log

Restart MySQL service


service mysqld restart


service mysql restart

If MariaDB installed

service mariadb restart

Tail the slow log file

tail -f /var/log/mysql-slow.log