These steps can help identify slow queries for mysql database
List all active MySQL processes.
mysql -u <DB_USER> -p <DB_PASSWORD> -e "SHOW FULL PROCESSLIST;" View the last 100 lines of the MySQL slow query log.
sudo tail -n 100 /var/log/mysql/mysql-slow.logDisplay the MySQL configuration file.
cat /etc/mysql/my.cnfShow disk space usage in a human-readable format.
df -hView the last 100 lines of the system log.
sudo tail -n 100 /var/log/syslogCheck the status of the MySQL service.
sudo systemctl status mysql.serviceConnect to the database and EXPLAIN a given slow query
mysql -u <DB_USER> -p <DB_PASSWORD> -e "USE <DB_NAME>; EXPLAIN <SLOW_QUERY>"