日期:2014-05-16  浏览次数:20765 次

mysql 几个有用的小命令

1 .? mysqladmin? -u 用于名 -p -h10.140.1.1?status

用于显示当前连接的情况

?

Uptime: 148310? Threads: 32? Questions: 130862? Slow queries: 0? Opens: 1154? Flush tables: 1? Open tables: 64? Queries per second avg: 0.882

其中的 Threads 就表示当前正在连接数,

?

2. mysqladmin -u 用户名?-p -h10.140.1.1 processlist

?

显示当前详细的连接情况

?

如下数据:

?

[root@bogon ~]# mysqladmin -u root processlist
+-------+------+--------------------+-----------+---------+------+-------+------------------+
| Id??? | User | Host?????????????? | db??????? | Command | Time | State | Info???????????? |
+-------+------+--------------------+-----------+---------+------+-------+------------------+
| 26638 | crm? | 192.168.1.81:1598? | freeiris2 | Sleep?? | 2554 |?????? |????????????????? |
| 26988 | crm? | 192.168.1.81:2052? | freeiris2 | Sleep?? | 4344 |?????? |????????????????? |
| 26990 | crm? | 192.168.1.81:2054? | freeiris2 | Sleep?? | 4018 |?????? |????????????????? |
| 27200 | crm? | 192.168.1.85:1806? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27202 | crm? | 192.168.1.85:1804? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27203 | crm? | 192.168.1.85:1807? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27204 | crm? | 192.168.1.85:1808? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27205 | crm? | 192.168.1.85:1809? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27206 | crm? | 192.168.1.85:1810? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27207 | crm? | 192.168.1.85:1811? | freeiris2 | Sleep?? | 6350 |?????? |????????????????? |
| 27208 | crm? | 192.168.1.85:1812? | freeiris2 | Sleep?? | 6338 |?????? |????????????????? |
| 27209 | crm? | 192.168.1.85:1813? | freeiris2 | Sleep?? | 6346 |?????? |????????????????? |
| 27356 | crm? | 192.168.1.188:1577 | freeiris2 | Sleep?? | 1884 |?????? |????????????????? |
| 27438 | crm? | 192.168.1.85:1874? | freeiris2 | Sleep?? | 5322 |?????? |????????????????? |
| 27439 | crm? | 192.168.1.85:1876? | freeiris2 | Sleep?? | 5324 |?????? |????????????????? |

?

就可以看到是哪个 IP 正在连接。

?

3.? 登录进? mysql 之后,执行 show variables

?

? 就会显示mysql 的系统变量信息。