You get a bonus - 1 coin for daily activity. Now you have 1 coin

MySQL: how to view processes (connections) or kill a specific process (connection)

Practice



For all operations you still need access to the MySQL console, at least via SSH. Moreover, the MySQL server must have free "connections" available, i.e. this method won't work if the server is stuck because all connections are used up (a DDoS attack, or a bug in the site's or software's code that keeps flooding the server with requests).


Process list

So, if we're connected via mysql:

$ mysql -u username -p
Password:


To see the current connections:

> SHOW PROCESSLIST;

If you don't use the FULL parameter, only the first 100 characters of the query will be shown. If you need to see queries in full - use:

> SHOW FULL PROCESSLIST;

This command outputs a list of processes with information about what each process is doing.


The same thing - but via mysqladmin:

$ mysqladmin -u username -p processlist


Killing a process

To "kill" a specific process - first look up its ID from PROCESSLIST, then run the command:

> KILL <ID>

Or via mysqladmin:

$ mysqladmin -u username -p kill <ID>

Where instead of <ID> you substitute the actual process ID.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)