2.show processlist 显示当前正在执行的mysql连接
mysql> show processlist;
+---------+----------+--------------------+-----------+---------+-------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+---------+----------+--------------------+-----------+---------+-------+-------+------------------+
| 1105357 | tjuser | 10.10.100.30:36210 | testdb | Sleep | 1377 | | NULL |
| 1112435 | tjuser | 10.10.100.30:54112 | testdb | Sleep | 1616 | | NULL |
|…… 略
| 1116128 | tjuser | 10.10.100.21:47484 | testdb | Sleep | 1 | | NULL |
| 1116129 | tjuser | 10.10.100.21:47485 | testdb | Sleep | 64 | | NULL |
+---------+----------+--------------------+-----------+---------+-------+-------+------------------+
207 rows in set (0.00 sec)
3.mysqladmin -u -p -h status 显示当前mysql状态
[root@db ~]# mysqladmin -uroot -p -hlocalhost status
Enter password:
Uptime: 14604445 Threads: 208 Questions: 34034734 Slow queries: 179 Opens: 12553 Flush tables: 3 Open tables: 977 Queries per second avg: 2.330
[root@db ~]#
4.mysqladmin -u -p -h extended-status 显示mysql的其他状态
[root@db ~]# mysqladmin -uroot -p -hlocalhost extended-status
Enter password:
+------------------------------------------+--------------+
| Variable_name | Value |
+------------------------------------------+--------------+
| Aborted_clients | 53041 |
| Aborted_connects | 163 |
| Connections | 1116157 |
…… 略
| Threads_connected | 206 |
| Threads_created | 633 |
| Threads_running | 1 |
| Uptime | 14604661 |
| Uptime_since_flush_status | 14604661 |
+------------------------------------------+--------------+
[root@db ~]#
三、总结
此次查询只需要掌握mysql中show status,show process list命令,以及命令mysqladmin。 通过上述命令可以快速得到MYSQL数据库连接参数与状态值。查询到数据库设置connect数为1000,告诉同事后修改了阈值后正常。
It’s never too late to be what you might have been.