简体   繁体   中英

Monitor MySQL connections from PHP (Open/Close)

Is there a tool that anyone knows that clearly shows something like this:

Opened Connection
   - Qry 1 executed... xyz time
   - Qry 2 executed... abc time
Connection Closed

Connections are from PHP to MySQL.

Does any profiler help?

yes, show processlist

mysql> show processlist;
+----+----------+-----------+--------+---------+------+------------+-------------------------------+
| Id | User     | Host      | db     | Command | Time | State      | Info                          |
+----+----------+-----------+--------+---------+------+------------+-------------------------------+
|  5 | jbolivar | localhost | SOF    | Query   |    0 | NULL       | show processlist              |
|  6 | jbolivar | localhost | sakila | Query   |    2 | User sleep | select *,sleep(20) from actor |
+----+----------+-----------+--------+---------+------+------------+-------------------------------+
2 rows in set (0.00 sec)

and if you want to kill the process you can use, kill query $ID

mysql> kill query 6;
Query OK, 0 rows affected (0.00 sec)

EDIT:

If you need a tool, take a look to mtop

You can use external tool like Sql profiler for this kind of task. I already have used Jet Sql Profiler ( http://www.jetprofiler.com ) but it's a commercial solution. I haven't found anything similar to Sql Server Profiler free for MySql yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM