· Mimi · Tech  · 2 min read

MySQL High CPU Usage on WHM

How to reduce persistent MySQL CPU load on WHM and tune key database settings.

If your WHM panel shows mysqld using more than 100% CPU or more, the issue is likely tied to slow queries, misconfigured memory settings, or excess open connections. This guide shows how to reduce that load without breaking sites or apps.

1. Enable and review slow query logs

Start by enabling the slow query log in my.cnf:

slow_query_log = 1
slow_query_log_file = /var/log/mysql-slow.log
long_query_time = 2

Restart MySQL and wait for logs to build. Then run:

mysqldumpslow -s t /var/log/mysql-slow.log

This sorts the slowest queries by count. Fixing even one of them can drop CPU use sharply.

2. Adjust InnoDB buffer pool size

On servers with free RAM, raise this setting:

innodb_buffer_pool_size = 4G

Use 60–70% of your available memory if InnoDB tables dominate your workload. This keeps queries from hitting disk.

3. Check open connections

Too many PHP or cPanel processes may leave idle MySQL threads open.

Run:

mysqladmin processlist

Then look for sleeping connections. If the count is high, lower max_connections or use persistent connection pooling via your app.

4. Audit missing indexes

Find slow queries and run EXPLAIN:

EXPLAIN SELECT * FROM your_table WHERE column = 'value';

If rows scanned is high and no key is shown, add an index on the relevant column.

5. Restart cleanly

Too many leftover connections or locked threads may require a graceful restart:

systemctl restart mysql

Restart at off-peak hours to avoid user interruptions.

With the slow log, memory tuning, and a few indexes, most servers cut MySQL CPU load by 50% or more in under a day.

Back to Blog

Related Posts

View All Posts »

Best Earbuds 2026

Top wireless earbuds to watch in 2026 — quality, features, and value.

Best Laptops 2026

Top laptop models expected in 2026, with features, use cases, and buying tips.