If you have MySQL administrative access, you can view and terminate active connections.
1. View active connections
SHOW PROCESSLIST;
or
SHOW FULL PROCESSLIST;
2. Kill a specific connection
Find the Id from the process list and run:
KILL 12345;
where 12345 is the connection ID.
3. Kill all sleeping connections
Generate KILL statements:
SELECT CONCAT('KILL ', id, ';')
FROM information_schema.processlist
WHERE COMMAND = 'Sleep';
Copy and execute the generated commands.
4. Kill all connections except your current session
SELECT CONCAT('KILL ',id,';')
FROM information_schema.processlist
WHERE id <> CONNECTION_ID();
On shared hosting
Many hosting providers (such as Hostinger, Bluehost, etc.) do not grant permission to kill MySQL connections. In that case:
- Wait for connections to time out.
- Restart the website/PHP processes if your control panel allows it.
- Contact hosting support and ask them to clear MySQL connections.
