Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Fix High mysqld CPU Usage on a Linux Server

A practical, no-restart workflow for finding the MySQL workload behind high Linux CPU usage and fixing it with evidence-driven query, index, or application changes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

High mysqld CPU usage is a symptom, not a diagnosis. The reliable fix is to capture the active workload, identify the statement or client responsible, inspect its execution plan, make one reversible query or index change, and then verify CPU, latency, and plan behavior. Changing global MySQL settings first often hides the cause and can make the incident harder to analyze.

This guide shows how to investigate a live Linux server without restarting MySQL, how to find both one-off and recurring offenders, and how to choose between a query rewrite, an index change, and an application-side fix.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start by proving what is consuming CPU

First establish whether the load is sustained, intermittent, or tied to a short burst. Record the time the spike began, the affected host, the MySQL process ID, and whether one thread or many threads are busy. A server with several concurrent queries can show high total CPU even when no single statement appears extreme.

At the Linux layer, inspect the mysqld process and its threads. For example:

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
pidof mysqld
top -H -p <mysqld-pid>
ps -L -p <mysqld-pid> -o pid,tid,pcpu,stat,etime,comm

Thread-level output helps distinguish one runaway worker from broad concurrency. Save a sample during the incident rather than relying on a later snapshot. There is no universal percentage at which MySQL becomes “too high”; hardware, schema, version, query mix, and traffic pattern determine what is abnormal for a particular server.

At the MySQL layer, immediately capture the process list:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysqladmin processlist status -u <admin-user> -p

MySQL’s debugging guidance specifically recommends mysqladmin processlist status when mysqld starts consuming CPU or memory or appears to hang, because it can reveal a statement that is taking a long time.

You can obtain the same view from a SQL session:

SHOW FULL PROCESSLIST;

SHOW FULL PROCESSLIST displays server-thread operations, including statement text, state, and elapsed time. Seeing other users’ threads requires the PROCESS privilege. Without it, you may see only your own sessions and could miss the actual offender.

On installations with Performance Schema enabled, query its process-list table as well:

SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO
FROM performance_schema.processlist
ORDER BY TIME DESC;

Capture the output before terminating anything. The connection ID, user, host, database, command, state, elapsed time, and full statement text are useful for both remediation and post-incident review.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read the process list correctly

A process-list row is a lead, not an automatic kill recommendation. Interpret the row in context:

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  • Command and state: an active query, sorting, copying to a temporary table, sending data, or waiting on a resource means something different from an idle connection.
  • Elapsed time: a long-running transaction may be legitimate reporting, a blocked operation, or a runaway request. Duration alone does not prove harm.
  • Statement text: look for broad scans, unbounded reports, repeated polling, or a request pattern that should have been batched.
  • Concurrency: many identical statements can consume more CPU collectively than one visibly slow query.
  • Sleep: an old session in Sleep is not necessarily using CPU. Do not kill sleeping connections simply because they are old.

Correlate the process list with the Linux samples. If one thread repeatedly appears at the top and its connection ID maps to an active statement, prioritize that statement. If CPU is spread across many identical statements, investigate the caller, connection pool, or polling loop rather than chasing a single session.

Terminate a session only when you can identify a clearly harmful workload, such as an accidental unbounded report or runaway client. Record the connection ID, user, host, statement, and reason before issuing a kill. A typical administrative action is:

KILL <connection-id>;

Killing a query can roll back work, hold locks during rollback, or leave the application with an error. It is an emergency containment step, not a performance fix. Preserve the evidence so the same workload can be corrected at its source.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find recurring expensive statements with the slow query log

The process list shows what is happening now. The slow query log shows statements that repeatedly exceed a threshold, including work that has finished before you connect. Set a threshold that fits the workload instead of assuming one universal value. A very low threshold on a busy server can generate substantial I/O and disk growth.

For a temporary investigation, administrators can enable the log and set a threshold dynamically:

SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 1;

The value of 1 is an example of a one-second threshold, not a recommendation for every system. Choose a value that captures problematic requests while keeping the log reviewable. Check the active file name before reading it:

SHOW VARIABLES LIKE 'slow_query_log_file';
SHOW VARIABLES LIKE 'long_query_time';
SHOW VARIABLES LIKE 'log_queries_not_using_indexes';

MySQL also provides log_queries_not_using_indexes. Enabling it can expose statements that perform row lookups without an index, but it may be noisy. A full scan is not automatically a defect: scanning a small table or returning most of a table can be the correct plan. Treat the setting as a way to generate candidates, then compare execution time, rows examined, call frequency, and business purpose.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Summarize a large slow log with mysqldumpslow. For example:

mysqldumpslow -s t -t 20 /path/to/your-slow.log

The -s t sort focuses on query time and -t 20 limits the output to the top 20 normalized patterns. Other sort choices can surface statements with the most executions or the largest lock time. Review both the normalized pattern and representative concrete queries; parameter values can change selectivity and therefore the best plan.

Runtime changes normally do not require a server restart, but a temporary setting is lost when the server restarts unless you place an intentional value in the appropriate MySQL configuration and schedule that change through your normal deployment process. Do not leave broad, high-volume logging enabled indefinitely without estimating storage, rotation, and collection overhead.

Use EXPLAIN to connect a statement to its cost

Run EXPLAIN on the exact statement captured from the process list or slow log. Test the same SQL shape, predicates, joins, ordering, and parameter characteristics that produced the CPU spike; a hand-edited approximation can produce a different plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
EXPLAIN
SELECT ...;

Read the plan as a chain of access decisions:

  • Access type: determine whether MySQL is using an efficient lookup, scanning an index, or scanning a table. A scan can be valid for a small relation or a query that returns most rows.
  • Possible and chosen keys: compare indexes MySQL considered with the one it selected. A missing or poorly ordered composite index may leave the optimizer with an expensive alternative.
  • Estimated rows: large estimates indicate how much data each step may process. Compare them with the query’s intended selectivity.
  • Join order and filtering: verify that selective conditions reduce rows before expensive joins, grouping, or sorting.
  • Temporary tables and filesorts: these are clues that grouping or ordering may require substantial work, especially when many rows reach that stage.

Common query-level fixes include:

  • Adding a composite index that follows the query’s selective equality predicates, then its range or ordering columns.
  • Removing accidental functions, expressions, or implicit casts from indexed columns when they prevent an index lookup.
  • Filtering and aggregating earlier so fewer rows enter joins and sorts.
  • Rewriting an N+1 request pattern into a set-based query or an intentional batch.

Do not add an index solely because a log says “not using indexes.” An index has storage cost, consumes memory, and adds work to inserts, updates, and deletes. Confirm that the target query benefits and that the write workload can absorb the additional maintenance.

Attribute intermittent CPU with Performance Schema

A query may finish before you can catch it in SHOW FULL PROCESSLIST. Performance Schema helps compare statement and thread activity during a spike with a quiet interval. It is low-level execution monitoring, separate from binary logging, and its instrumentation does not change query execution plans.

For statement-digest summaries, a query such as the following can rank accumulated work:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
SELECT DIGEST_TEXT,
       COUNT_STAR,
       SUM_TIMER_WAIT / 1000000000000 AS total_seconds,
       AVG_TIMER_WAIT / 1000000000000 AS average_seconds
FROM performance_schema.events_statements_summary_by_digest
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 20;

Use the results to separate high total cost from high per-call cost. A statement with modest latency but millions of executions may be the CPU consumer, while a rare report may dominate individual latency without explaining sustained load.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

During an active spike, combine digest data with the current process list and operating-system samples. If instrumentation is disabled or incomplete, state that limitation and use the slow query log, application metrics, and Linux sampling together. Avoid enabling every available instrument permanently without estimating overhead and retention; high-volume history can consume CPU, memory, and disk.

Slow log or Performance Schema?

Question Slow query log Performance Schema
Best for Historical statements that crossed a configured threshold Current and accumulated statement/thread attribution
When it helps most Recurring slow work that is no longer running Short spikes and workload comparison between intervals
Retention File-based; depends on rotation and collection In-memory summaries and configured history
Main caution Low thresholds can create large logs and I/O Incomplete instrumentation can leave gaps
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the smallest effective fix

Once attribution is solid, change one layer at a time. The right fix may be a query rewrite, an index, or an application correction rather than a global server setting.

Option Read performance Write and storage cost Plan stability Rollback
Query rewrite Can reduce rows, joins, sorts, or round trips directly Usually no new index storage; code changes may affect callers Depends on the rewritten shape and statistics Revert application change or feature flag
New or adjusted index Can turn a scan into a selective lookup Consumes storage and adds write amplification May change plans for other statements Drop the specific index after confirming dependencies
Application or workload fix Can remove duplicate polling, N+1 calls, or accidental reports May require coordinated deployment Often improves load broadly, but behavior must be monitored Rollback the client release or disable the workload

Before changing anything, preserve the original SQL, its EXPLAIN output, relevant configuration values, and the current index definition. This creates a rollback record and lets you distinguish a real improvement from a workload shift.

When a query rewrite is preferable

Rewrite when the statement requests more data than the feature needs, applies functions to indexed columns, performs repeated single-row lookups, or sorts and joins large intermediate sets. Keep the result semantics identical and test edge cases such as nulls, duplicate rows, time zones, and pagination boundaries. A rewrite that reduces average latency but changes result order or completeness is not a valid fix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When an index is preferable

Add an index when the plan shows a selective predicate or join condition without a suitable access path. For a multi-column index, place equality predicates before range or ordering columns when that matches the query’s filtering pattern. Verify the chosen key and estimated rows after creation, and check representative write traffic. Do not create overlapping indexes blindly; redundant structures increase maintenance without guaranteeing a better plan.

When the application is the source

Repeated identical statements, bursts tied to a background job, and N+1 request patterns often require an application change. Inspect request rates, connection-pool behavior, retry loops, and polling intervals. Limiting concurrency or batching work can reduce CPU more safely than changing optimizer-related settings globally.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Validate without restarting MySQL

Validation must use representative traffic, not only a quiet maintenance window. After one change, compare a before-and-after interval long enough to include the workload that caused the incident.

  • CPU: total mysqld utilization and, when useful, per-thread distribution.
  • Latency: statement execution time at the percentiles your application monitors.
  • Throughput: executions per second and completed requests.
  • Rows examined: whether the server processes fewer rows for the same result.
  • Lock waits: whether the change shifts pressure from CPU to contention.
  • Slow-log volume: whether recurring expensive statements decline at the selected threshold.
  • Plan behavior: the new EXPLAIN output, chosen key, estimated rows, join order, and sort or temporary-table indicators.

Keep the old plan and metrics beside the new ones. If CPU stays high, return to attribution instead of stacking unrelated configuration changes. The remaining load may come from a different statement, increased concurrency, a changed data distribution, or an external workload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common failure modes and recovery paths

The process list shows only sleeping sessions

Check your privileges, capture a fresh sample during the spike, and inspect Performance Schema or the slow log for statements that completed between snapshots. Sleeping connections are not proof that they caused CPU usage.

A query says it is not using an index

Run EXPLAIN and compare the estimated rows and returned fraction. A full scan can be the cheapest plan for a small table or a query that returns most rows. Add an index only when the workload and plan show a selective access path is missing.

Adding an index did not lower CPU

Confirm that the production statement uses the same predicates and data types as the tested query. Check the chosen key in the new plan, execution frequency, and whether another digest dominates total time. The index may be correct but irrelevant to the actual offender.

Enabling logging created a new problem

Raise the threshold, disable log_queries_not_using_indexes after collecting candidates, rotate or archive the log, and estimate disk growth before re-enabling broad capture. Keep enough evidence to identify the recurring statements without turning diagnostics into sustained I/O pressure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Killing a query caused a long rollback

Monitor the connection and transaction until rollback completes, and check whether locks remain held. Record the incident and fix the client or statement that created the runaway transaction; repeated killing without source correction will recur.

A repeatable incident checklist

  1. Record the start time, host, mysqld process ID, total CPU, and whether load is sustained.
  2. Capture Linux process and thread samples while the spike is active.
  3. Run mysqladmin processlist status, SHOW FULL PROCESSLIST, and, when available, query performance_schema.processlist.
  4. Map active connection IDs to statement text, state, elapsed time, user, and host. Do not kill sessions merely because they are old or sleeping.
  5. Enable a workload-appropriate slow-log threshold temporarily and summarize the file with mysqldumpslow.
  6. Use Performance Schema summaries to find intermittent or high-frequency work that the process list missed.
  7. Run EXPLAIN on the exact offending statement and inspect access type, keys, rows, joins, filtering, temporary tables, and filesorts.
  8. Choose one reversible fix: stop the accidental workload, rewrite the query, add or adjust a justified index, or correct the connection/request pattern.
  9. Validate CPU, latency, executions, rows examined, lock waits, slow-log volume, and the before/after plan under representative traffic.
  10. If the result is inconclusive, roll back the change and return to attribution rather than changing several global settings at once.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.