Diagnose MySQL slow query performance Issues

1

List all active MySQL processes.

mysql -u <DB_USER> -p <DB_PASSWORD>  -e "SHOW FULL PROCESSLIST;" 
2

View the last 100 lines of the MySQL slow query log.

sudo tail -n 100 /var/log/mysql/mysql-slow.log
3

Display the MySQL configuration file.

cat /etc/mysql/my.cnf
4

Show disk space usage in a human-readable format.

df -h
5

View the last 100 lines of the system log.

sudo tail -n 100 /var/log/syslog
6

Check the status of the MySQL service.

sudo systemctl status mysql.service
7

Connect to the database and EXPLAIN a given slow query

mysql -u <DB_USER> -p <DB_PASSWORD> -e "USE <DB_NAME>; EXPLAIN <SLOW_QUERY>"