Jichao
Jichao

Reputation: 41785

How to manage MySQL connections within MySQL?

Wehn I test the following PDO code, I could view the connections to MySQL in MySQL with show processlist, but how could I cut off one connection? Is there any other power tool for managing MySQL connection/etc other than command line?

<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass, array(PDO::ATTR_PERSISTENT => true));
// use the connection here


// and now we're done; close it
$dbh = null;
?>

Upvotes: 1

Views: 312

Answers (1)

Pekka
Pekka

Reputation: 449385

I've never worked with it, but there's KILL that looks like what you're looking for.

Each connection to mysqld runs in a separate thread. You can see which threads are running with the SHOW PROCESSLIST statement and kill a thread with the KILL thread_id statement.

In MySQL 5.0.0, KILL permits an optional CONNECTION or QUERY modifier:

Upvotes: 3

Related Questions