When a website suddenly feels slow, times out, or shows a database error under load, the cause is often a single MySQL query that is taking too long to finish and is holding up everything else that needs the database. phpMyAdmin lets you see every query currently running against your database and stop the one that is causing the problem, without needing any command line access.
Opening phpMyAdmin
You can reach phpMyAdmin from either control panel. Once you are inside it, the steps below are identical regardless of which panel your hosting uses.
- In cPanel, go to the Databases section and click phpMyAdmin.
- In DirectAdmin, go to the MySQL Management section and click phpMyAdmin.
Viewing currently running queries
- Once phpMyAdmin opens, click the Status tab along the top.
- Scroll down to the section labeled List of processes (on some versions this appears as its own Processes tab instead).
- You'll see a table listing every active connection to the database: its Id, the User running it, how long it has been running under Time (in seconds), its State, and the actual SQL query text under Info.
- Click the heading of the Time column to sort the list so the longest-running queries appear at the top.
A query that has been running for several minutes, especially one repeated many times with a high Time value, is usually the one slowing your site down. Look at the Info column to see which table or page on your website it relates to.
Stopping a problem query
- Find the row for the query you want to stop.
- At the end of that row, click Kill.
- Confirm the action when prompted.
Killing a query only stops that one running statement; it does not delete any data that has already been saved. It's generally safe for a query that has been stuck for an unusually long time, but avoid killing queries you don't recognize if your site appears to be working normally; a few short-lived connections running at any moment is normal.
Preventing it from happening again
- If the same query keeps reappearing and running long, it's often caused by a specific plugin, report, or search feature on your website that needs to be optimized or run less frequently.
- Check whether a scheduled task, bulk import, or backup process is running at the same time as the slow query; competing for the database at once can make ordinary queries take far longer than usual.
- If a particular table is involved every time, it may help to add an index to it or reduce its size; ask your developer to review the query if it's part of custom code.
If you're not sure which query is responsible or the problem keeps coming back, see how to access phpMyAdmin in cPanel and DirectAdmin for a refresher on getting into phpMyAdmin, and open a support ticket so we can look at the database load with you.